#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); int result = 0, min_np = 1005, np = 0; for(int i=1; i<=n; ++i){ int a; scanf("%d", &a); result+=a; if(a%2 == 1){ np++; min_np = min(min_np, a); } } if(np%2 == 1) result-=min_np; if(result == 0) puts("NIESTETY"); else printf("%d\n", result); 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 | #include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); int result = 0, min_np = 1005, np = 0; for(int i=1; i<=n; ++i){ int a; scanf("%d", &a); result+=a; if(a%2 == 1){ np++; min_np = min(min_np, a); } } if(np%2 == 1) result-=min_np; if(result == 0) puts("NIESTETY"); else printf("%d\n", result); return 0; } |