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