#include <cstdio>
const int MAXN = 1005;
int main() {
int n;
int res = 0;
int num_odds = 0, smallest_odd = MAXN;
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
int a;
scanf("%d", &a);
res += a;
if (a % 2 == 1) {
++num_odds;
if (a < smallest_odd) {
smallest_odd = a;
}
}
}
if (smallest_odd == MAXN) {
smallest_odd = 0;
}
if (num_odds % 2 == 1) {
res -= smallest_odd;
}
if (res == 0) {
printf("NIESTETY\n");
} else {
printf("%d\n", res);
}
return 0;
}
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 31 32 33 | #include <cstdio> const int MAXN = 1005; int main() { int n; int res = 0; int num_odds = 0, smallest_odd = MAXN; scanf("%d", &n); for (int i = 0; i < n; ++i) { int a; scanf("%d", &a); res += a; if (a % 2 == 1) { ++num_odds; if (a < smallest_odd) { smallest_odd = a; } } } if (smallest_odd == MAXN) { smallest_odd = 0; } if (num_odds % 2 == 1) { res -= smallest_odd; } if (res == 0) { printf("NIESTETY\n"); } else { printf("%d\n", res); } return 0; } |
English