#include <iostream>
#define MAXVAL 1000000
using namespace std;
int main() {
int n, temp, min_odd_val;
long sum;
cin >> n;
if (n == 1) {
cin >> temp;
if (temp % 2 == 0)
cout << temp;
else
cout << "NIESTETY";
}
else {
sum = 0;
min_odd_val = MAXVAL+1;
for (int i = 0; i != n; i++) {
cin >> temp;
sum += temp;
if (temp % 2 == 1 && min_odd_val > temp)
min_odd_val = temp;
}
if (sum % 2 == 0)
cout << sum;
else
cout << sum - min_odd_val;
}
cout << 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 | #include <iostream> #define MAXVAL 1000000 using namespace std; int main() { int n, temp, min_odd_val; long sum; cin >> n; if (n == 1) { cin >> temp; if (temp % 2 == 0) cout << temp; else cout << "NIESTETY"; } else { sum = 0; min_odd_val = MAXVAL+1; for (int i = 0; i != n; i++) { cin >> temp; sum += temp; if (temp % 2 == 1 && min_odd_val > temp) min_odd_val = temp; } if (sum % 2 == 0) cout << sum; else cout << sum - min_odd_val; } cout << endl; } |
English