#include <cstdio> #include <algorithm> const int INF = 1e9; int main() { int n; scanf("%d", &n); int odd_count = 0; int result = 0; int min_odd = INF; for (int i=0; i<n; i++) { int value; scanf("%d", &value); result += value; if (value % 2 == 1) { min_odd = std::min(min_odd, value); odd_count++; } } if (odd_count % 2 == 1) result -= min_odd; if (result == 0) printf("NIESTETY\n"); else printf("%d\n", result); }
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 | #include <cstdio> #include <algorithm> const int INF = 1e9; int main() { int n; scanf("%d", &n); int odd_count = 0; int result = 0; int min_odd = INF; for (int i=0; i<n; i++) { int value; scanf("%d", &value); result += value; if (value % 2 == 1) { min_odd = std::min(min_odd, value); odd_count++; } } if (odd_count % 2 == 1) result -= min_odd; if (result == 0) printf("NIESTETY\n"); else printf("%d\n", result); } |