#include <iostream> #include <cstdio> using namespace std; const int MAXINT = 1000001; main() { int result=0,minNiep=MAXINT,ileNiep=0,n; cin >> n; while(n--) { int a; cin >> a; if(a%2==0) result+=a; else { minNiep=min(minNiep,a); result+=a; ileNiep++; } } if(ileNiep%2==1) result-=minNiep; if(result==0) cout << "NIESTETY"; else cout << result; }
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 <iostream> #include <cstdio> using namespace std; const int MAXINT = 1000001; main() { int result=0,minNiep=MAXINT,ileNiep=0,n; cin >> n; while(n--) { int a; cin >> a; if(a%2==0) result+=a; else { minNiep=min(minNiep,a); result+=a; ileNiep++; } } if(ileNiep%2==1) result-=minNiep; if(result==0) cout << "NIESTETY"; else cout << result; } |