#include <iostream> #include <cstdlib> int main( int argc, char* argv[] ) { uint32_t n; bool odd_found = false; uint16_t min_odd = 0; uint64_t s = 0; std::cin >> n; uint32_t i = 0; uint32_t t; if( n == 1 ) { std::cin >> t; if( (1&t) == 1 ) std::cout << "NIESTETY" << std::endl; else std::cout << t << std::endl; return 0; } while( i<n && !odd_found ) { std::cin >> t; s += t; if( ( 1 & t) == 1 ) { odd_found = true; min_odd = t; } ++i; } while( i<n ) { std::cin >> t; s += t; if( t < min_odd & ( (1 & t) == 1 ) ) { min_odd = t; } ++i; } if( ( s & 1 ) == 0 ) { if( s == 0 ) std::cout << "NIESTETY" << std::endl; else std::cout << s << std::endl; return 0; } if( ( (s & 1) == 1 ) && !odd_found ) { std::cout << "NIESTETY" << std::endl; return 0; } std::cout << s-min_odd << 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 51 52 53 54 55 56 57 58 59 60 61 62 | #include <iostream> #include <cstdlib> int main( int argc, char* argv[] ) { uint32_t n; bool odd_found = false; uint16_t min_odd = 0; uint64_t s = 0; std::cin >> n; uint32_t i = 0; uint32_t t; if( n == 1 ) { std::cin >> t; if( (1&t) == 1 ) std::cout << "NIESTETY" << std::endl; else std::cout << t << std::endl; return 0; } while( i<n && !odd_found ) { std::cin >> t; s += t; if( ( 1 & t) == 1 ) { odd_found = true; min_odd = t; } ++i; } while( i<n ) { std::cin >> t; s += t; if( t < min_odd & ( (1 & t) == 1 ) ) { min_odd = t; } ++i; } if( ( s & 1 ) == 0 ) { if( s == 0 ) std::cout << "NIESTETY" << std::endl; else std::cout << s << std::endl; return 0; } if( ( (s & 1) == 1 ) && !odd_found ) { std::cout << "NIESTETY" << std::endl; return 0; } std::cout << s-min_odd << std::endl; return 0; } |