/* Tomasz [Tommalla] Zakrzewski, Potyczki Algorytmiczne 2015 / / Seria I, Grupa B, Zadanie "Kieszonkowe" */ #include <cstdio> const int INF = 99999999; int main() { int n, sum = 0, minOdd = INF, next; scanf("%d", &n); while (n--) { scanf("%d", &next); sum += next; if (next % 2 == 1) { minOdd = minOdd > next ? next : minOdd; } } if (sum % 2 == 1 && (minOdd == 0 || minOdd == sum)) { puts("NIESTETY"); return 0; } if (sum % 2 == 1) { sum -= minOdd; } printf("%d\n", sum); 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 | /* Tomasz [Tommalla] Zakrzewski, Potyczki Algorytmiczne 2015 / / Seria I, Grupa B, Zadanie "Kieszonkowe" */ #include <cstdio> const int INF = 99999999; int main() { int n, sum = 0, minOdd = INF, next; scanf("%d", &n); while (n--) { scanf("%d", &next); sum += next; if (next % 2 == 1) { minOdd = minOdd > next ? next : minOdd; } } if (sum % 2 == 1 && (minOdd == 0 || minOdd == sum)) { puts("NIESTETY"); return 0; } if (sum % 2 == 1) { sum -= minOdd; } printf("%d\n", sum); return 0; } |