#include <iostream> using llu = unsigned long long int; int main() { std::ios_base::sync_with_stdio(0); /* P + P = P N + N = P P + N = N */ llu n; std::cin >> n; llu ans = 0; int min_odd = 10000; int a; for (int i = 0; i < n; i++) { std::cin >> a; ans += a; if (a < min_odd && (a & 1)) { min_odd = a; } } // std::cerr << "Ans = " << ans << std::endl; if ((ans & 1) == 0) { // Even std::cout << ans << std::endl; return 0; } else { // Odd if (min_odd != 10000) { if (ans - min_odd == 0) { std::cout << "NIESTETY" << std::endl; return 0; } else { std::cout << (ans - min_odd) << std::endl; return 0; } } } 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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | #include <iostream> using llu = unsigned long long int; int main() { std::ios_base::sync_with_stdio(0); /* P + P = P N + N = P P + N = N */ llu n; std::cin >> n; llu ans = 0; int min_odd = 10000; int a; for (int i = 0; i < n; i++) { std::cin >> a; ans += a; if (a < min_odd && (a & 1)) { min_odd = a; } } // std::cerr << "Ans = " << ans << std::endl; if ((ans & 1) == 0) { // Even std::cout << ans << std::endl; return 0; } else { // Odd if (min_odd != 10000) { if (ans - min_odd == 0) { std::cout << "NIESTETY" << std::endl; return 0; } else { std::cout << (ans - min_odd) << std::endl; return 0; } } } return 0; } |