#include <iostream> #include <cstdint> #include <limits> int main() { std::ios_base::sync_with_stdio(0); uint32_t N = 0; uint32_t even_sum = 0, odd_sum = 0; uint32_t odd_num = 0; uint32_t odd_min = std::numeric_limits<uint32_t>::max(); std::cin >> N; // for (uint32_t i = 0; i < N; ++i) { uint32_t temp = 0; std::cin >> temp; if (temp % 2 == 0) { even_sum += temp; } else { odd_sum += temp; odd_min = std::min(odd_min, temp); odd_num++; } } // if (even_sum == 0 && odd_num == 1) { std::cout << "NIESTETY" << std::endl; return 0; } // if (odd_num % 2 != 0) { odd_sum -= odd_min; } std::cout << even_sum + odd_sum << std::endl; 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 | #include <iostream> #include <cstdint> #include <limits> int main() { std::ios_base::sync_with_stdio(0); uint32_t N = 0; uint32_t even_sum = 0, odd_sum = 0; uint32_t odd_num = 0; uint32_t odd_min = std::numeric_limits<uint32_t>::max(); std::cin >> N; // for (uint32_t i = 0; i < N; ++i) { uint32_t temp = 0; std::cin >> temp; if (temp % 2 == 0) { even_sum += temp; } else { odd_sum += temp; odd_min = std::min(odd_min, temp); odd_num++; } } // if (even_sum == 0 && odd_num == 1) { std::cout << "NIESTETY" << std::endl; return 0; } // if (odd_num % 2 != 0) { odd_sum -= odd_min; } std::cout << even_sum + odd_sum << std::endl; return 0; } |