#include <cstdio> #define MIN 99999 int sum = 0, min = MIN, n, x; int main() { scanf("%d", &n); for (int i=0; i<n; i++) { scanf("%d", &x); sum += x; if (x%2 && min>x) min = x; } if (sum%2 && min!=MIN) sum -= min; if (sum%2==0 && sum>0) printf("%d\n", sum); else printf("NIESTETY\n"); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include <cstdio> #define MIN 99999 int sum = 0, min = MIN, n, x; int main() { scanf("%d", &n); for (int i=0; i<n; i++) { scanf("%d", &x); sum += x; if (x%2 && min>x) min = x; } if (sum%2 && min!=MIN) sum -= min; if (sum%2==0 && sum>0) printf("%d\n", sum); else printf("NIESTETY\n"); } |