#include <bits/stdc++.h> int main() { int n; scanf("%d", &n); int low = 1000000007; int sum = 0; for (int i = 0; i < n; ++i) { int x; scanf("%d", &x); if (x % 2 == 0) sum += x; else { if (low > x) { low = x; } sum += x; } } if (sum % 2 == 1) sum -= low; if (sum == 0) printf("NIESTETY\n"); 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 | #include <bits/stdc++.h> int main() { int n; scanf("%d", &n); int low = 1000000007; int sum = 0; for (int i = 0; i < n; ++i) { int x; scanf("%d", &x); if (x % 2 == 0) sum += x; else { if (low > x) { low = x; } sum += x; } } if (sum % 2 == 1) sum -= low; if (sum == 0) printf("NIESTETY\n"); else printf("%d\n", sum); } |