#include <stdio.h>
#include <limits>
int main()
{
int n;
scanf("%d", &n);
int sum = 0, value = 0, smallestOdd = std::numeric_limits<int>::max();
for (int i = 0; i < n; ++i)
{
scanf("%d", &value);
sum += value;
if (value % 2 == 1 && value < smallestOdd)
smallestOdd = value;
}
if (sum == smallestOdd)
{
printf("NIESTETY\n");
return 0;
}
if (sum % 2 == 0)
printf("%d\n", sum);
else
printf("%d\n", sum - smallestOdd);
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 | #include <stdio.h> #include <limits> int main() { int n; scanf("%d", &n); int sum = 0, value = 0, smallestOdd = std::numeric_limits<int>::max(); for (int i = 0; i < n; ++i) { scanf("%d", &value); sum += value; if (value % 2 == 1 && value < smallestOdd) smallestOdd = value; } if (sum == smallestOdd) { printf("NIESTETY\n"); return 0; } if (sum % 2 == 0) printf("%d\n", sum); else printf("%d\n", sum - smallestOdd); return 0; } |
English