#include <bits/stdc++.h> using namespace std; int main(void) { int n; scanf("%d", &n); if (n == 1) { int tmp; scanf("%d", &tmp); if (tmp % 2) puts("NIESTETY"); else printf("%d\n", tmp); return 0; } int res = 0; int MIN = 1e9+7; while (n--) { int tmp; scanf("%d", &tmp); if (tmp % 2) MIN = min(MIN, tmp); res += tmp; } if (res % 2) res -= MIN; printf("%d\n", res); 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 <bits/stdc++.h> using namespace std; int main(void) { int n; scanf("%d", &n); if (n == 1) { int tmp; scanf("%d", &tmp); if (tmp % 2) puts("NIESTETY"); else printf("%d\n", tmp); return 0; } int res = 0; int MIN = 1e9+7; while (n--) { int tmp; scanf("%d", &tmp); if (tmp % 2) MIN = min(MIN, tmp); res += tmp; } if (res % 2) res -= MIN; printf("%d\n", res); return 0; } |