#include <cstdint> #include <iostream> #include <limits> int main() { std::uint_fast32_t n; std::cin >> n; std::uint_fast32_t sum = 0; std::uint_fast32_t odds_count = 0; std::uint_fast16_t lowest_odd = std::numeric_limits<decltype(lowest_odd)>::max(); for (decltype(n) i = 0; i < n; ++i) { std::uint_fast16_t note; std::cin >> note; sum += note; if (note & 1) { ++odds_count; if (note < lowest_odd) lowest_odd = note; } } if (odds_count & 1) { sum -= lowest_odd; } if (sum) std::cout << sum; else std::cout << "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 28 29 30 31 32 33 34 35 36 37 | #include <cstdint> #include <iostream> #include <limits> int main() { std::uint_fast32_t n; std::cin >> n; std::uint_fast32_t sum = 0; std::uint_fast32_t odds_count = 0; std::uint_fast16_t lowest_odd = std::numeric_limits<decltype(lowest_odd)>::max(); for (decltype(n) i = 0; i < n; ++i) { std::uint_fast16_t note; std::cin >> note; sum += note; if (note & 1) { ++odds_count; if (note < lowest_odd) lowest_odd = note; } } if (odds_count & 1) { sum -= lowest_odd; } if (sum) std::cout << sum; else std::cout << "NIESTETY"; } |