#include <algorithm>
#include <iostream>
using namespace std;
int main() {
int n, m;
int smallest_odd = 1001;
int s = 0;
scanf("%d", &n);
for(int i = 0; i < n; ++i){
scanf("%d", &m);
s += m;
if((m & 1) && (m < smallest_odd)){
smallest_odd = m;
}
}
if(s & 1){
if(n == 1){
printf("%s\n", "NIESTETY");
return 0;
}else{
s -= smallest_odd;
}
}
printf("%d\n", s);
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 33 | #include <algorithm> #include <iostream> using namespace std; int main() { int n, m; int smallest_odd = 1001; int s = 0; scanf("%d", &n); for(int i = 0; i < n; ++i){ scanf("%d", &m); s += m; if((m & 1) && (m < smallest_odd)){ smallest_odd = m; } } if(s & 1){ if(n == 1){ printf("%s\n", "NIESTETY"); return 0; }else{ s -= smallest_odd; } } printf("%d\n", s); return 0; } |
polski