#include <iostream> using namespace std; int main() { int n; cin >> n; int oddCount = 0; int evenCount = 0; int smallestOdd = 1000; int sum = 0; for (int i = 0; i < n; ++i) { int number; cin >> number; if (number % 2 == 0) { evenCount++; } else { oddCount++; if (smallestOdd > number) { smallestOdd = number; } } sum += number; } if (oddCount % 2 != 0) { sum -= smallestOdd; } if (sum == 0) { cout << "NIESTETY" << endl; } else { cout << sum << 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 | #include <iostream> using namespace std; int main() { int n; cin >> n; int oddCount = 0; int evenCount = 0; int smallestOdd = 1000; int sum = 0; for (int i = 0; i < n; ++i) { int number; cin >> number; if (number % 2 == 0) { evenCount++; } else { oddCount++; if (smallestOdd > number) { smallestOdd = number; } } sum += number; } if (oddCount % 2 != 0) { sum -= smallestOdd; } if (sum == 0) { cout << "NIESTETY" << endl; } else { cout << sum << endl; } return 0; } |