#include<cstdio> int main() { const long long INF = 1001; long long n, sum = 0, x, minimum = INF; scanf("%lld", &n); while (--n) { scanf("%lld", &x); if (x < minimum && x % 2 == 1) { if (minimum < INF) sum += minimum; minimum = x; } else sum += x; } if (sum == 0) printf("NIESTETY\n"); else { if (sum % 2 == 1) sum += minimum; printf("%lld\n", sum); } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include<cstdio> int main() { const long long INF = 1001; long long n, sum = 0, x, minimum = INF; scanf("%lld", &n); while (--n) { scanf("%lld", &x); if (x < minimum && x % 2 == 1) { if (minimum < INF) sum += minimum; minimum = x; } else sum += x; } if (sum == 0) printf("NIESTETY\n"); else { if (sum % 2 == 1) sum += minimum; printf("%lld\n", sum); } } |