Advertisement
ec1117

Untitled

Mar 6th, 2022
1,027
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <fstream>
  4. #include <set>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int odd = 0;
  10.     int even = 0;
  11.     int x, y;
  12.     cin >> y;
  13.     for (int i = 0; i < y; i++) {
  14.         cin >> x;
  15.         if (x % 2 == 0) even++;
  16.         else odd++;
  17.     }
  18.     while (odd > even) {
  19.         odd--;
  20.         odd--;
  21.         even++;
  22.     }
  23.     if (even > odd + 1)even = odd + 1;
  24.     cout << even + odd;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement