#include <iostream> #include <vector> #include <unordered_map> using namespace std; int n; int main() { ios_base::sync_with_stdio(false); cin >> n; vector<unsigned> v(n); unsigned oddcnt = 0; unsigned totalsum = 0; for (int i = 0; i < n; ++i) { cin >> v[i]; oddcnt += (v[i] & 1) ? 1 : 0; totalsum += v[i]; } if (oddcnt & 1) { unsigned best = totalsum; for (int i = 0; i < n; ++i) { if ((v[i] & 1) && v[i] < best) { best = v[i]; } } totalsum -= best; } if (totalsum != 0) { cout << totalsum << 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 | #include <iostream> #include <vector> #include <unordered_map> using namespace std; int n; int main() { ios_base::sync_with_stdio(false); cin >> n; vector<unsigned> v(n); unsigned oddcnt = 0; unsigned totalsum = 0; for (int i = 0; i < n; ++i) { cin >> v[i]; oddcnt += (v[i] & 1) ? 1 : 0; totalsum += v[i]; } if (oddcnt & 1) { unsigned best = totalsum; for (int i = 0; i < n; ++i) { if ((v[i] & 1) && v[i] < best) { best = v[i]; } } totalsum -= best; } if (totalsum != 0) { cout << totalsum << endl; } else { cout << "NIESTETY" << endl; } return 0; } |