#include <cstdio> #include <algorithm> int main () { int n; scanf ("%d", &n); int current; int min_odd = 1043; bool odd_odd = false; int result = 0; while (n--) { scanf("%d", ¤t); if (current & 1) { min_odd = std::min(min_odd, current); odd_odd = !odd_odd; } result += current; } if (odd_odd) result -= min_odd; if (result > 0) printf("%d\n", result); 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 22 23 24 25 26 27 28 29 30 31 | #include <cstdio> #include <algorithm> int main () { int n; scanf ("%d", &n); int current; int min_odd = 1043; bool odd_odd = false; int result = 0; while (n--) { scanf("%d", ¤t); if (current & 1) { min_odd = std::min(min_odd, current); odd_odd = !odd_odd; } result += current; } if (odd_odd) result -= min_odd; if (result > 0) printf("%d\n", result); else printf("NIESTETY\n"); return 0; } |