#include <iostream> using namespace std; int main() { unsigned int count; unsigned int suma = 0; unsigned int minOdd = 0; unsigned int next; cin >> count; for(unsigned int i=0; i<count; ++i) { cin >> next; suma += next; if(next&1) { if((minOdd==0) or (minOdd>next)) { minOdd = next; } } } if(suma&1) { suma -= minOdd; } if(suma>0) cout << suma; else cout << "NIESTETY"; }
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 | #include <iostream> using namespace std; int main() { unsigned int count; unsigned int suma = 0; unsigned int minOdd = 0; unsigned int next; cin >> count; for(unsigned int i=0; i<count; ++i) { cin >> next; suma += next; if(next&1) { if((minOdd==0) or (minOdd>next)) { minOdd = next; } } } if(suma&1) { suma -= minOdd; } if(suma>0) cout << suma; else cout << "NIESTETY"; } |