#include <stdio.h> int main() { int sum = 0, ai, n, min_odd = 1001; scanf("%d", &n); for (int i=0; i<n; ++i) { scanf("%d", &ai); sum += ai; if ((ai & 1) && ai < min_odd) { min_odd = ai; } } if (sum % 2 == 0) { printf("%d\n", sum); } else { if (min_odd < sum) { printf("%d\n", sum - min_odd); } else { puts("NIESTETY"); } } 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 <stdio.h> int main() { int sum = 0, ai, n, min_odd = 1001; scanf("%d", &n); for (int i=0; i<n; ++i) { scanf("%d", &ai); sum += ai; if ((ai & 1) && ai < min_odd) { min_odd = ai; } } if (sum % 2 == 0) { printf("%d\n", sum); } else { if (min_odd < sum) { printf("%d\n", sum - min_odd); } else { puts("NIESTETY"); } } return 0; } |