#include<iostream> using namespace std; long t, i, x, sum = 0, minnp = -1; int main() { cin >> t; for (int i = 0; i < t; ++i) { cin >> x; sum += x; if (x%2==1 && (minnp==-1 || x<minnp)) minnp = x; }; if (sum%2==1) sum -= minnp; if (sum > 0) cout << sum; else cout << "NIESTETY"; return 0; };
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include<iostream> using namespace std; long t, i, x, sum = 0, minnp = -1; int main() { cin >> t; for (int i = 0; i < t; ++i) { cin >> x; sum += x; if (x%2==1 && (minnp==-1 || x<minnp)) minnp = x; }; if (sum%2==1) sum -= minnp; if (sum > 0) cout << sum; else cout << "NIESTETY"; return 0; }; |