#ifdef _MSC_VER #define _CRT_SECURE_NO_WARNINGS #endif #include <iostream> #include <cstdio> int main() { int minOdd = 1001; int oddCount = 0; int total = 0; int n; scanf("%d", &n); for (int i = 0; i < n; i++) { int val; scanf("%d", &val); total += val; if (val % 2 == 1) { minOdd = minOdd > val ? val : minOdd; oddCount++; } } if (n == 1 && oddCount == 1) { printf("NIESTETY\n"); } else { printf("%d\n", (oddCount % 2 == 1) ? total - minOdd : total); } 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 32 33 34 35 36 37 38 39 | #ifdef _MSC_VER #define _CRT_SECURE_NO_WARNINGS #endif #include <iostream> #include <cstdio> int main() { int minOdd = 1001; int oddCount = 0; int total = 0; int n; scanf("%d", &n); for (int i = 0; i < n; i++) { int val; scanf("%d", &val); total += val; if (val % 2 == 1) { minOdd = minOdd > val ? val : minOdd; oddCount++; } } if (n == 1 && oddCount == 1) { printf("NIESTETY\n"); } else { printf("%d\n", (oddCount % 2 == 1) ? total - minOdd : total); } return 0; } |