// kie.cpp : Defines the entry point for the console application. // #include <iostream> #include <vector> using namespace std; int main(int argc, char* argv[]) { int N; scanf("%d", &N); int curr; int sum = 0; int min_nieparzyste = 0x7F11FF11; for(int i=0; i<N; i++) { scanf("%d", &curr); sum += curr; if(curr % 2 == 1) { min_nieparzyste = min(min_nieparzyste, curr); } } if(sum%2==0) { cout << sum << endl; } else { // sum % 2 == 1 if(N==1) cout << "NIESTETY\n"; else cout << (sum- min_nieparzyste) << 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 | // kie.cpp : Defines the entry point for the console application. // #include <iostream> #include <vector> using namespace std; int main(int argc, char* argv[]) { int N; scanf("%d", &N); int curr; int sum = 0; int min_nieparzyste = 0x7F11FF11; for(int i=0; i<N; i++) { scanf("%d", &curr); sum += curr; if(curr % 2 == 1) { min_nieparzyste = min(min_nieparzyste, curr); } } if(sum%2==0) { cout << sum << endl; } else { // sum % 2 == 1 if(N==1) cout << "NIESTETY\n"; else cout << (sum- min_nieparzyste) << endl; } return 0; } |