#include <iostream> using namespace std; int main () { int bajt, x, halo=1000; long long suma=0; cin >>bajt; for (int start=0; start<bajt ; start++) { cin>>x; suma+=x; if (x%2==1) { if(halo>x) { halo=x; } } } if(suma%2==1 && suma-halo==0) { cout << "NIESTETY"; } else { if(suma%2==1) { cout << suma-halo; } else { cout << suma; } } }
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 34 35 36 | #include <iostream> using namespace std; int main () { int bajt, x, halo=1000; long long suma=0; cin >>bajt; for (int start=0; start<bajt ; start++) { cin>>x; suma+=x; if (x%2==1) { if(halo>x) { halo=x; } } } if(suma%2==1 && suma-halo==0) { cout << "NIESTETY"; } else { if(suma%2==1) { cout << suma-halo; } else { cout << suma; } } } |