#include <cstdio> int banknotes[1000000]; int n; int main() { scanf("%d", &n); int sum = 0; int lowest_odd = -1; for(int i=0; i<n; i++) { int a; scanf("%d", &a); sum += a; if (a%2==1) { if (lowest_odd == -1 || a < lowest_odd) { lowest_odd = a; } } } if (sum%2 == 0) { printf("%d", sum); } else if (lowest_odd == -1){ printf("NIESTETY"); } else { if (sum - lowest_odd == 0) { printf ("NIESTETY"); } else { printf("%d", sum - lowest_odd); } } 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 | #include <cstdio> int banknotes[1000000]; int n; int main() { scanf("%d", &n); int sum = 0; int lowest_odd = -1; for(int i=0; i<n; i++) { int a; scanf("%d", &a); sum += a; if (a%2==1) { if (lowest_odd == -1 || a < lowest_odd) { lowest_odd = a; } } } if (sum%2 == 0) { printf("%d", sum); } else if (lowest_odd == -1){ printf("NIESTETY"); } else { if (sum - lowest_odd == 0) { printf ("NIESTETY"); } else { printf("%d", sum - lowest_odd); } } return 0; } |