#include <stdio.h> int main() { int n, sum = 0, tmp, min = 1001; scanf("%d", &n); for (int i=0; i<n; ++i) { scanf("%d", &tmp); sum += tmp; if (tmp % 2 == 1 && tmp < min) min = tmp; } if (sum % 2 == 0) printf("%d\n", sum); else if (min != 1001 && sum != min) printf("%d\n", sum - min); else printf("NIESTETY\n"); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <stdio.h> int main() { int n, sum = 0, tmp, min = 1001; scanf("%d", &n); for (int i=0; i<n; ++i) { scanf("%d", &tmp); sum += tmp; if (tmp % 2 == 1 && tmp < min) min = tmp; } if (sum % 2 == 0) printf("%d\n", sum); else if (min != 1001 && sum != min) printf("%d\n", sum - min); else printf("NIESTETY\n"); return 0; } |