#include<bits/stdc++.h> using namespace std; int main() { int m = -1; int s = 0; int n; scanf("%d", &n); while(n--) { int a; scanf("%d", &a); s += a; if(a % 2) if(m == -1 || a < m) m = a; } if(s % 2 == 0) printf("%d\n", s); else if(m != -1 && m != s) printf("%d\n", s - m); else puts("NIESTETY"); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include<bits/stdc++.h> using namespace std; int main() { int m = -1; int s = 0; int n; scanf("%d", &n); while(n--) { int a; scanf("%d", &a); s += a; if(a % 2) if(m == -1 || a < m) m = a; } if(s % 2 == 0) printf("%d\n", s); else if(m != -1 && m != s) printf("%d\n", s - m); else puts("NIESTETY"); return 0; } |