#include <cstdio> int N, a, s, am, ac; int main() { scanf("%d", &N); s = 0; am = 1000; ac = 0; for (int i = 0; i < N; i++) { scanf("%d", &a); s += a; if (a % 2 == 1) { ac = 1 - ac; if (a < am) { am = a; } } } s -= ac * am; if (s > 0) { printf("%d\n", s); } else { printf("NIESTETY\n"); } 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 | #include <cstdio> int N, a, s, am, ac; int main() { scanf("%d", &N); s = 0; am = 1000; ac = 0; for (int i = 0; i < N; i++) { scanf("%d", &a); s += a; if (a % 2 == 1) { ac = 1 - ac; if (a < am) { am = a; } } } s -= ac * am; if (s > 0) { printf("%d\n", s); } else { printf("NIESTETY\n"); } return 0; } |