#include <cstdio> int main(void) { unsigned n; scanf("%d", &n); unsigned short bill = 1001; unsigned sum = 0; unsigned short * tab = new unsigned short[n]; for (unsigned i =0u; i < n; i++) { scanf("%hu", (tab+i)); sum += tab[i]; if ((tab[i] % 2) && (tab[i] < bill)) bill = tab[i]; } if (sum % 2) { if (sum == bill) printf("NIESTETY"); else printf("%u", sum - bill); } else { printf("%u", sum); } delete [] tab; 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 | #include <cstdio> int main(void) { unsigned n; scanf("%d", &n); unsigned short bill = 1001; unsigned sum = 0; unsigned short * tab = new unsigned short[n]; for (unsigned i =0u; i < n; i++) { scanf("%hu", (tab+i)); sum += tab[i]; if ((tab[i] % 2) && (tab[i] < bill)) bill = tab[i]; } if (sum % 2) { if (sum == bill) printf("NIESTETY"); else printf("%u", sum - bill); } else { printf("%u", sum); } delete [] tab; return 0; } |