#include <cstdio> int main() { int n, k, minOdd = 1000002, suma = 0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &k); if (k % 2 == 1 && k < minOdd) minOdd = k; suma += k; } if (suma % 2 == 0) { printf("%d", suma); return 0; } if (minOdd == suma) { printf("NIESTETY"); return 0; } printf("%d\n", suma - minOdd); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <cstdio> int main() { int n, k, minOdd = 1000002, suma = 0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &k); if (k % 2 == 1 && k < minOdd) minOdd = k; suma += k; } if (suma % 2 == 0) { printf("%d", suma); return 0; } if (minOdd == suma) { printf("NIESTETY"); return 0; } printf("%d\n", suma - minOdd); } |