#include <limits.h> #include <stdio.h> #include <stdlib.h> int main() { int n, i, c, odd, min_odd, sum; scanf("%d", &n); odd = 0; sum = 0; min_odd = INT_MAX; for (i = 0; i < n; i++) { scanf("%d", &c); if (c & 1) { odd = odd + 1; if (c < min_odd) { min_odd = c; } } sum = sum + c; } if (odd & 1) { sum = sum - min_odd; } if (sum) { printf("%d\n", sum); } else { printf("NIESTETY"); } 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 | #include <limits.h> #include <stdio.h> #include <stdlib.h> int main() { int n, i, c, odd, min_odd, sum; scanf("%d", &n); odd = 0; sum = 0; min_odd = INT_MAX; for (i = 0; i < n; i++) { scanf("%d", &c); if (c & 1) { odd = odd + 1; if (c < min_odd) { min_odd = c; } } sum = sum + c; } if (odd & 1) { sum = sum - min_odd; } if (sum) { printf("%d\n", sum); } else { printf("NIESTETY"); } return EXIT_SUCCESS; } |