#include <bits/stdc++.h> int main() { long long n; scanf("%lld", &n); long long lowestOdd = 0; long long sum = 0; for (long long i = 0; i < n; ++i) { long long v; scanf("%lld", &v); sum += v; if ((v%2)==1 && (lowestOdd == 0 || v < lowestOdd)) lowestOdd = v; } if ((sum % 2 == 0)) printf("%lld", sum); else if (n > 1 && lowestOdd>0) printf("%lld", sum - lowestOdd); else printf("NIESTETY"); }
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 <bits/stdc++.h> int main() { long long n; scanf("%lld", &n); long long lowestOdd = 0; long long sum = 0; for (long long i = 0; i < n; ++i) { long long v; scanf("%lld", &v); sum += v; if ((v%2)==1 && (lowestOdd == 0 || v < lowestOdd)) lowestOdd = v; } if ((sum % 2 == 0)) printf("%lld", sum); else if (n > 1 && lowestOdd>0) printf("%lld", sum - lowestOdd); else printf("NIESTETY"); } |