#include <algorithm> #include <cstdio> #include <cstdlib> #include <iostream> #include <limits> #include <climits> #include <map> #include <set> #include <vector> const long long LLMAX = (std::numeric_limits<long long>()).max(); const long long LLMIN = (std::numeric_limits<long long>()).min(); int main() { std::ios_base::sync_with_stdio(false); int n; scanf("%d", &n); int sum = 0; int lowest_odd = INT_MAX; for (int i=0; i < n; ++i) { int ai; scanf("%d", &ai); sum += ai; if (lowest_odd > ai && ai % 2 == 1) { lowest_odd = ai; } } int amount = sum - ((sum % 2 == 0) ? 0 : lowest_odd); if (amount > 0) { printf("%d\n", amount); } else { printf("NIESTETY\n"); } }
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 36 | #include <algorithm> #include <cstdio> #include <cstdlib> #include <iostream> #include <limits> #include <climits> #include <map> #include <set> #include <vector> const long long LLMAX = (std::numeric_limits<long long>()).max(); const long long LLMIN = (std::numeric_limits<long long>()).min(); int main() { std::ios_base::sync_with_stdio(false); int n; scanf("%d", &n); int sum = 0; int lowest_odd = INT_MAX; for (int i=0; i < n; ++i) { int ai; scanf("%d", &ai); sum += ai; if (lowest_odd > ai && ai % 2 == 1) { lowest_odd = ai; } } int amount = sum - ((sum % 2 == 0) ? 0 : lowest_odd); if (amount > 0) { printf("%d\n", amount); } else { printf("NIESTETY\n"); } } |