#include <cstdio>
#include <algorithm>
using namespace std;
const int MAX_ODD = 1001;
int n, x, min_odd = MAX_ODD, odd_ct, odd_sum, even_sum;
int main() {
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
scanf("%d", &x);
if (x % 2) {
min_odd = min(x, min_odd);
odd_ct++;
odd_sum += x;
}
else
even_sum += x;
}
if (even_sum == 0 && odd_ct == 1) {
printf("NIESTETY");
return 0;
}
int res = even_sum + odd_sum;
if (odd_ct % 2)
res -= min_odd;
printf("%d", res);
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #include <cstdio> #include <algorithm> using namespace std; const int MAX_ODD = 1001; int n, x, min_odd = MAX_ODD, odd_ct, odd_sum, even_sum; int main() { scanf("%d", &n); for (int i = 0; i < n; ++i) { scanf("%d", &x); if (x % 2) { min_odd = min(x, min_odd); odd_ct++; odd_sum += x; } else even_sum += x; } if (even_sum == 0 && odd_ct == 1) { printf("NIESTETY"); return 0; } int res = even_sum + odd_sum; if (odd_ct % 2) res -= min_odd; printf("%d", res); } |
English