#include <cstdio> #include <vector> const int MAX_N = 1000009; int nc, sum, nmin; int main() { int n; scanf("%d", &n); nmin = 1009; for (int i = 0; i < n; ++i) { int a; scanf("%d", &a); sum += a; if (a&1) { ++nc; if (a < nmin) nmin = a; } } if (nc&1) { if (nmin == sum) { printf("NIESTETY\n"); } else { printf("%d\n", sum-nmin); } } else { printf("%d\n", sum); } }
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 | #include <cstdio> #include <vector> const int MAX_N = 1000009; int nc, sum, nmin; int main() { int n; scanf("%d", &n); nmin = 1009; for (int i = 0; i < n; ++i) { int a; scanf("%d", &a); sum += a; if (a&1) { ++nc; if (a < nmin) nmin = a; } } if (nc&1) { if (nmin == sum) { printf("NIESTETY\n"); } else { printf("%d\n", sum-nmin); } } else { printf("%d\n", sum); } } |