#include <vector> #include <stdio.h> using namespace std; int main() { int size, in, lowest = 1001, sum = 0; scanf("%d", &size); for (int i=0; i<size; ++i){ scanf("%d", &in); sum += in; if (in % 2 != 0 && in < lowest) { lowest = in; } } if (size == 1 && sum % 2 == 1) { printf("NIESTETY\n"); } else if (sum % 2 == 1) { printf("%d\n", sum - lowest); } else { printf("%d\n", sum); } 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 | #include <vector> #include <stdio.h> using namespace std; int main() { int size, in, lowest = 1001, sum = 0; scanf("%d", &size); for (int i=0; i<size; ++i){ scanf("%d", &in); sum += in; if (in % 2 != 0 && in < lowest) { lowest = in; } } if (size == 1 && sum % 2 == 1) { printf("NIESTETY\n"); } else if (sum % 2 == 1) { printf("%d\n", sum - lowest); } else { printf("%d\n", sum); } return 0; } |