题解
2023-09-01 09:58:42
发布于:广东
6阅读
0回复
0点赞
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
int even = 0;
int odd = 0;
for (int i = 0; i < n; i++) {
int cow;
cin >> cow;
if (cow % 2 == 0) {
even++;
} else {
odd++;
}
}
while (odd > even) {
odd = odd - 2;
even++;
}
if (even > odd + 1) { even = odd + 1; }
cout << odd + even << endl;
}
这里空空如也
有帮助,赞一个