#include <cstdio> using namespace std; int main() { int n, res = 0, x, minOdd = 1000000, countOdd = 0; scanf("%d", &n); for(int i = 0;i < n;++i) { scanf("%d", &x); if(x%2 == 1) { ++countOdd; if(x < minOdd) minOdd = x; } res += x; } if(countOdd%2 == 1) res -= minOdd; if(res > 0) printf("%d\n", res); else printf("NIESTETY\n"); 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 | #include <cstdio> using namespace std; int main() { int n, res = 0, x, minOdd = 1000000, countOdd = 0; scanf("%d", &n); for(int i = 0;i < n;++i) { scanf("%d", &x); if(x%2 == 1) { ++countOdd; if(x < minOdd) minOdd = x; } res += x; } if(countOdd%2 == 1) res -= minOdd; if(res > 0) printf("%d\n", res); else printf("NIESTETY\n"); return 0; } |