#include <cstdio> #include <algorithm> #define INF 1001 int n, a, min_np, sum; int main () { min_np = INF; scanf("%d", &n); while (n--) { scanf("%d", &a); if (a%2 == 1) min_np = std::min(min_np, a); sum += a; } if (sum%2 == 0) { printf("%d\n", sum); } else if (min_np != INF && sum - min_np > 0) { printf("%d\n", sum - min_np); } else { printf("NIESTETY\n"); } }
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 <cstdio> #include <algorithm> #define INF 1001 int n, a, min_np, sum; int main () { min_np = INF; scanf("%d", &n); while (n--) { scanf("%d", &a); if (a%2 == 1) min_np = std::min(min_np, a); sum += a; } if (sum%2 == 0) { printf("%d\n", sum); } else if (min_np != INF && sum - min_np > 0) { printf("%d\n", sum - min_np); } else { printf("NIESTETY\n"); } } |