#include <algorithm> #include <cassert> #include <iostream> #include <vector> using namespace std; namespace { constexpr int inf = 1222333444; int solve(vector<int> const& data) { int sum = 0; int best = inf; for (auto const& x: data) { sum += x; if (x % 2 == 1 && x < best) best = x; } if (sum % 2 == 0) return sum; return sum - best; } } int main() { iostream::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> data(n); for (auto& a: data) { cin >> a; } auto res = solve(move(data)); if (res > 0) { assert(res % 2 == 0); cout << res << '\n'; } else { cout << "NIESTETY\n"; } 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 | #include <algorithm> #include <cassert> #include <iostream> #include <vector> using namespace std; namespace { constexpr int inf = 1222333444; int solve(vector<int> const& data) { int sum = 0; int best = inf; for (auto const& x: data) { sum += x; if (x % 2 == 1 && x < best) best = x; } if (sum % 2 == 0) return sum; return sum - best; } } int main() { iostream::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> data(n); for (auto& a: data) { cin >> a; } auto res = solve(move(data)); if (res > 0) { assert(res % 2 == 0); cout << res << '\n'; } else { cout << "NIESTETY\n"; } return 0; } |