#include<iostream> using namespace std; int main() { int a, b, sumcia1, sumcia2, min, y, op; int T [1006]; cin >> a; y=0; min=10000; for (int i=0; i<a; i++) { cin >> T[i]; } int k; k=0; b=0; for (int j=0; j<a; j++) { k+= T[j]; b++; } if (b==1) { if (k%2==0) cout << k << endl; else cout << "NIESTETY" << endl; } else { if (k%2==0) { sumcia1= k; cout << sumcia1; } else { for (int z=0;z<=b;z++) { if (T[z]%2!=0) { if(min>T[z]) min=T[z]; } } sumcia2=k-min; cout<<sumcia2 << endl; } } 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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | #include<iostream> using namespace std; int main() { int a, b, sumcia1, sumcia2, min, y, op; int T [1006]; cin >> a; y=0; min=10000; for (int i=0; i<a; i++) { cin >> T[i]; } int k; k=0; b=0; for (int j=0; j<a; j++) { k+= T[j]; b++; } if (b==1) { if (k%2==0) cout << k << endl; else cout << "NIESTETY" << endl; } else { if (k%2==0) { sumcia1= k; cout << sumcia1; } else { for (int z=0;z<=b;z++) { if (T[z]%2!=0) { if(min>T[z]) min=T[z]; } } sumcia2=k-min; cout<<sumcia2 << endl; } } return 0; } |