#include <iostream> using namespace std; int main(void) { ios_base::sync_with_stdio(0); int sum = 0, moneyCount = 0; int temp = 0; cin >> moneyCount; if(moneyCount==1) { cout << "NIESTETY" << endl; return 0; } for(int x = 0;x<moneyCount;++x) { cin >> temp; sum += temp; } if( (sum%2) == 0 ) { cout << sum << endl; } else { if( (sum-1) != 0 && (sum-1) != 1) { cout << sum-3 << 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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #include <iostream> using namespace std; int main(void) { ios_base::sync_with_stdio(0); int sum = 0, moneyCount = 0; int temp = 0; cin >> moneyCount; if(moneyCount==1) { cout << "NIESTETY" << endl; return 0; } for(int x = 0;x<moneyCount;++x) { cin >> temp; sum += temp; } if( (sum%2) == 0 ) { cout << sum << endl; } else { if( (sum-1) != 0 && (sum-1) != 1) { cout << sum-3 << endl; } else { cout << "NIESTETY" << endl; } } return 0; } |