#include<cstdlib>
#include<cstdio>
using namespace std;
int main(int argc, char * argv[])
{
int total;
scanf("%d", &total);
int smallestOdd = 1001;
long long all = 0;
for (int i = 0; i < total; i++)
{
int number;
scanf("%d", &number);
if ((number % 2) == 1)
{
if (number < smallestOdd)
smallestOdd = number;
}
all += number;
}
if ((all % 2) == 1)
{
if (total == 1)
{
printf("NIESTETY");
return EXIT_SUCCESS;
}
else
{
all -= smallestOdd;
}
}
printf("%lld", all);
return EXIT_SUCCESS;
}
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 41 42 43 | #include<cstdlib> #include<cstdio> using namespace std; int main(int argc, char * argv[]) { int total; scanf("%d", &total); int smallestOdd = 1001; long long all = 0; for (int i = 0; i < total; i++) { int number; scanf("%d", &number); if ((number % 2) == 1) { if (number < smallestOdd) smallestOdd = number; } all += number; } if ((all % 2) == 1) { if (total == 1) { printf("NIESTETY"); return EXIT_SUCCESS; } else { all -= smallestOdd; } } printf("%lld", all); return EXIT_SUCCESS; } |
English