#include <iostream> using namespace std; const int m = 1000; int main() { int n,j, temp, min_n; long long suma_e, suma_n; cin >> n; j = 0; suma_n = 0; suma_e = 0; min_n = 0; for (int i = 0; i < n; i++){ cin >> temp; if (temp & 1) { suma_n += temp; if (min_n==0) min_n = temp; else min_n = min(min_n,temp); j++; } else { suma_e += temp; } } if (suma_e == 0 && j < 2) std::cout <<"NIESTETY"<<endl; else { long long res = suma_e + suma_n; if (res & 1) res -= min_n; std::cout << res << 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 35 36 37 38 | #include <iostream> using namespace std; const int m = 1000; int main() { int n,j, temp, min_n; long long suma_e, suma_n; cin >> n; j = 0; suma_n = 0; suma_e = 0; min_n = 0; for (int i = 0; i < n; i++){ cin >> temp; if (temp & 1) { suma_n += temp; if (min_n==0) min_n = temp; else min_n = min(min_n,temp); j++; } else { suma_e += temp; } } if (suma_e == 0 && j < 2) std::cout <<"NIESTETY"<<endl; else { long long res = suma_e + suma_n; if (res & 1) res -= min_n; std::cout << res << endl; } } |