#include <iostream> #include <cstdlib> #include <cstdio> #include <cmath> using namespace std; #define min(a,b) (a<b)?a:b int main() { int n, s, a, l; l = 3000; s = 0; scanf("%d", &n); while (n --> 0) { scanf("%d", &a); s += a; if (a % 2 == 1) { l = min(l, a); } } if (s % 2 == 0 && s != 0) { printf("%d", s); return 0; } if (l % 2 == 1 && s - l > 0) printf("%d", s - l); else printf("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 34 35 | #include <iostream> #include <cstdlib> #include <cstdio> #include <cmath> using namespace std; #define min(a,b) (a<b)?a:b int main() { int n, s, a, l; l = 3000; s = 0; scanf("%d", &n); while (n --> 0) { scanf("%d", &a); s += a; if (a % 2 == 1) { l = min(l, a); } } if (s % 2 == 0 && s != 0) { printf("%d", s); return 0; } if (l % 2 == 1 && s - l > 0) printf("%d", s - l); else printf("NIESTETY"); return 0; } |