Codeforces Round 874 (Div. 3) 1833C - Vlad Building Beautiful Array Solution



Problem Link :  https://codeforces.com/contest/1833/problem/C
Solution in C++:
  1. /// Author : AH_Tonmoy
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. int32_t main() {
  5. ios_base::sync_with_stdio(0);
  6. cin.tie(0);
  7. int t;
  8. cin >> t;
  9. while (t--) {
  10. int n , x ;
  11. cin >> n ;
  12. int mn = 1e9+5 , ev = 0 , odd = 0 ;
  13. for ( int i = 0 ; i < n ; i++){
  14. cin >> x ;
  15. mn = min ( x , mn ) ;
  16. if ( x % 2 == 0){
  17. ev++;
  18. }
  19. }
  20. if (ev == n ) cout <<"YES"<<endl;
  21. else{
  22. if ( mn % 2 == 1 ) {
  23. cout <<"YES"<<endl;
  24. }
  25. else cout <<"NO"<<endl;
  26. }
  27. }
  28. return 0;
  29. }

No comments

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h ...

Powered by Blogger.