#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
int sumOfBills = 0;
int N;
cin >> N;
int a;
int minOdd = 1000;
int numOddBills = 0;
for (int i=0; i<N; ++i) {
cin >> a;
if (a % 2 == 0)
sumOfBills += a;
else {
++numOddBills;
sumOfBills += a;
if (a < minOdd)
minOdd = a;
}
}
if (numOddBills % 2 != 0) {
sumOfBills -= minOdd;
}
if (sumOfBills == 0)
printf("NIESTETY\n");
else
printf("%d\n", sumOfBills);
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 | #include <iostream> #include <stdio.h> #include <vector> using namespace std; int main() { int sumOfBills = 0; int N; cin >> N; int a; int minOdd = 1000; int numOddBills = 0; for (int i=0; i<N; ++i) { cin >> a; if (a % 2 == 0) sumOfBills += a; else { ++numOddBills; sumOfBills += a; if (a < minOdd) minOdd = a; } } if (numOddBills % 2 != 0) { sumOfBills -= minOdd; } if (sumOfBills == 0) printf("NIESTETY\n"); else printf("%d\n", sumOfBills); return 0; } |
English