#include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(false); int n,suma = 0, x, najmn_niep = 1001; cin >> n; for(int i =0; i < n; i++){ cin >> x; suma += x; if(x % 2 == 1) najmn_niep = min(najmn_niep, x); } if(suma % 2 == 1) suma -= najmn_niep; if(suma!=0) cout << suma << endl; else cout << "NIESTETY" << 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 | #include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(false); int n,suma = 0, x, najmn_niep = 1001; cin >> n; for(int i =0; i < n; i++){ cin >> x; suma += x; if(x % 2 == 1) najmn_niep = min(najmn_niep, x); } if(suma % 2 == 1) suma -= najmn_niep; if(suma!=0) cout << suma << endl; else cout << "NIESTETY" << endl; return 0; } |