#include<iostream> using namespace std; int main() { int n, suma=0; bool par=true; cin >> n; short int a,b=1000; for (int i=0;i<n;i++) { cin >> a; suma+=a; if (a%2==1) {par=!par; if(a<b) b=a;} } if(!par) suma-=b; if(suma!=0) cout << suma; else cout << "NIESTETY"; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include<iostream> using namespace std; int main() { int n, suma=0; bool par=true; cin >> n; short int a,b=1000; for (int i=0;i<n;i++) { cin >> a; suma+=a; if (a%2==1) {par=!par; if(a<b) b=a;} } if(!par) suma-=b; if(suma!=0) cout << suma; else cout << "NIESTETY"; return 0; } |