#include <iostream> #include <cstdlib> #define endl "\n" typedef long long ll; using namespace std; int n, pom, nnp = -1; ll sum = 0LL; void read(){ cin >> n; for (int i = 0; i < n; i ++){ cin >> pom; if (pom%2 && (nnp == -1 || pom < nnp)) nnp = pom; sum += pom; } } void solve(){ if (!(sum%2)) cout << sum << endl; else if (sum - nnp) cout << sum - nnp << endl; else cout << "NIESTETY" << endl; } int main() { ios_base::sync_with_stdio(0); read(); solve(); 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 | #include <iostream> #include <cstdlib> #define endl "\n" typedef long long ll; using namespace std; int n, pom, nnp = -1; ll sum = 0LL; void read(){ cin >> n; for (int i = 0; i < n; i ++){ cin >> pom; if (pom%2 && (nnp == -1 || pom < nnp)) nnp = pom; sum += pom; } } void solve(){ if (!(sum%2)) cout << sum << endl; else if (sum - nnp) cout << sum - nnp << endl; else cout << "NIESTETY" << endl; } int main() { ios_base::sync_with_stdio(0); read(); solve(); return 0; } |