#include <climits> #include <iostream> using namespace std; int main() { int n, value, minOdd = INT_MAX; long long sum = 0; ios_base::sync_with_stdio(false); cin >> n; for (int i = 0; i < n; i++) { cin >> value; sum += value; if (value % 2 == 1) { minOdd = min(minOdd, value); } } if (n == 1 && sum % 2 == 1) { cout << "NIESTETY" << endl; return 0; } if (sum % 2 == 1) { cout << sum - minOdd << endl; return 0; } cout << sum << endl; }
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 | #include <climits> #include <iostream> using namespace std; int main() { int n, value, minOdd = INT_MAX; long long sum = 0; ios_base::sync_with_stdio(false); cin >> n; for (int i = 0; i < n; i++) { cin >> value; sum += value; if (value % 2 == 1) { minOdd = min(minOdd, value); } } if (n == 1 && sum % 2 == 1) { cout << "NIESTETY" << endl; return 0; } if (sum % 2 == 1) { cout << sum - minOdd << endl; return 0; } cout << sum << endl; } |