#include <bits/stdc++.h> using namespace std; //typedef long long LL; int main(){ int n, ai, kie = 0, min1 = 1000000001; cin >> n; if (n == 1){ cin >> ai; if (ai & 1) cout << "NIESTETY\n"; else cout << ai << endl; return 0; } while (n--){ cin >> ai; if ((ai & 1) && ai < min1 ) min1 = ai; kie += ai; } if (kie & 1) kie -= min1; cout << kie << endl; }
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 | #include <bits/stdc++.h> using namespace std; //typedef long long LL; int main(){ int n, ai, kie = 0, min1 = 1000000001; cin >> n; if (n == 1){ cin >> ai; if (ai & 1) cout << "NIESTETY\n"; else cout << ai << endl; return 0; } while (n--){ cin >> ai; if ((ai & 1) && ai < min1 ) min1 = ai; kie += ai; } if (kie & 1) kie -= min1; cout << kie << endl; } |