/* * kieszonkowe.cpp * * Created on: 29 wrz 2015 * Author: segfault */ #include <cstdio> int main() { int count; scanf("%d", &count); int result = 0, min_odd = 1e9; int curr; for (int i = 0; i < count; i++) { scanf("%d", &curr); result += curr; if (curr % 2 == 1 && curr < min_odd) { min_odd = curr; } } if (result % 2 == 1) { result -= min_odd; } if (result == 0) { printf("NIESTETY"); } else { printf("%d", 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 27 28 29 30 31 32 33 34 35 | /* * kieszonkowe.cpp * * Created on: 29 wrz 2015 * Author: segfault */ #include <cstdio> int main() { int count; scanf("%d", &count); int result = 0, min_odd = 1e9; int curr; for (int i = 0; i < count; i++) { scanf("%d", &curr); result += curr; if (curr % 2 == 1 && curr < min_odd) { min_odd = curr; } } if (result % 2 == 1) { result -= min_odd; } if (result == 0) { printf("NIESTETY"); } else { printf("%d", result); } } |