#include <stdio.h> int main(int argc, char *argv[]) { int ii, bank, ile, min_odd = 0, sum = 0, ile_odd = 0; scanf("%d\n", &ile); for (ii = 0; ii < ile; ii ++) { scanf("%d", &bank); sum += bank; if (bank & 1) { if ((min_odd == 0) || (min_odd > bank)) { min_odd = bank; } ile_odd++; } } if (ile_odd & 1) { sum -= min_odd; } if (sum) { printf("%d\n", sum); } else { printf("NIESTETY\n"); } 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 | #include <stdio.h> int main(int argc, char *argv[]) { int ii, bank, ile, min_odd = 0, sum = 0, ile_odd = 0; scanf("%d\n", &ile); for (ii = 0; ii < ile; ii ++) { scanf("%d", &bank); sum += bank; if (bank & 1) { if ((min_odd == 0) || (min_odd > bank)) { min_odd = bank; } ile_odd++; } } if (ile_odd & 1) { sum -= min_odd; } if (sum) { printf("%d\n", sum); } else { printf("NIESTETY\n"); } return 0; } |