#include <iostream> #include <vector> using namespace std; int main() { ios::sync_with_stdio(0); int n; cin >> n; int suma = 0; int min_odd = 1000; vector<int> a(n); for(int i=0; i<n; ++i) { cin >> a[i]; suma += a[i]; if(a[i]%2 && a[i]<min_odd) min_odd = a[i]; } if(suma%2==0) cout << suma << endl; else if(n==1) cout << "NIESTETY" << endl; else cout << suma - min_odd << 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 27 28 29 30 31 32 33 34 | #include <iostream> #include <vector> using namespace std; int main() { ios::sync_with_stdio(0); int n; cin >> n; int suma = 0; int min_odd = 1000; vector<int> a(n); for(int i=0; i<n; ++i) { cin >> a[i]; suma += a[i]; if(a[i]%2 && a[i]<min_odd) min_odd = a[i]; } if(suma%2==0) cout << suma << endl; else if(n==1) cout << "NIESTETY" << endl; else cout << suma - min_odd << endl; } |