#include <bits/stdc++.h> using namespace std; int main () { ios_base::sync_with_stdio(0); int n, a, res=0, mini=1000000; cin >> n; for (int i=1; i<=n; i++) { cin >> a; if (a % 2 ==1) mini= min(a, mini); res+=a; } if (n==1 & res % 2==1) cout << "NIESTETY\n"; else { if (res % 2 ==1) res-=mini; cout << res << "\n"; } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include <bits/stdc++.h> using namespace std; int main () { ios_base::sync_with_stdio(0); int n, a, res=0, mini=1000000; cin >> n; for (int i=1; i<=n; i++) { cin >> a; if (a % 2 ==1) mini= min(a, mini); res+=a; } if (n==1 & res % 2==1) cout << "NIESTETY\n"; else { if (res % 2 ==1) res-=mini; cout << res << "\n"; } } |