#include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(0); int n, il_niep = 0, min_niep = 1000, s = 0, a, i; cin >> n; for(i = 0; i < n; ++i) { cin >> a; s += a; if (a % 2 == 1) { il_niep++; min_niep = min(min_niep, a); } } if ( n==1) { if (il_niep == 1) cout <<"NIESTETY"; else cout << s; } else if (il_niep % 2 == 0) cout << s; else cout << s - min_niep; 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 | #include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(0); int n, il_niep = 0, min_niep = 1000, s = 0, a, i; cin >> n; for(i = 0; i < n; ++i) { cin >> a; s += a; if (a % 2 == 1) { il_niep++; min_niep = min(min_niep, a); } } if ( n==1) { if (il_niep == 1) cout <<"NIESTETY"; else cout << s; } else if (il_niep % 2 == 0) cout << s; else cout << s - min_niep; return 0; } |