#include <iostream>
using namespace std;
int main() {
std::ios_base::sync_with_stdio (false);
long n;
cin >> n;
long sumeven = 0;
long sumodd = 0;
long minodd = 1001;
long countodd = 0;
long note = 0;
for (long i = 0; i < n; ++i) {
cin >> note;
if (note % 2 == 0) {
sumeven += note;
} else {
++countodd;
sumodd += note;
if (note < minodd) {
minodd = note;
}
}
}
if (n == 1 && countodd == 1) {
cout << "NIESTETY" << endl;
return 0;
}
if (countodd % 2 == 1) {
sumodd -= minodd;
}
cout << sumodd + sumeven << endl;
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | #include <iostream> using namespace std; int main() { std::ios_base::sync_with_stdio (false); long n; cin >> n; long sumeven = 0; long sumodd = 0; long minodd = 1001; long countodd = 0; long note = 0; for (long i = 0; i < n; ++i) { cin >> note; if (note % 2 == 0) { sumeven += note; } else { ++countodd; sumodd += note; if (note < minodd) { minodd = note; } } } if (n == 1 && countodd == 1) { cout << "NIESTETY" << endl; return 0; } if (countodd % 2 == 1) { sumodd -= minodd; } cout << sumodd + sumeven << endl; return 0; } |
English