#include <iostream> int main() { long long unsigned int n, v, sum=0, smalestOdd=1001; std::cin >> n; for (long long unsigned int i=0; i<n; i++) { std::cin >> v; sum+=v; if ((v%2) && (smalestOdd > v)) smalestOdd=v; } if (! (sum%2)) { std::cout << sum << std::endl; } else { sum-=smalestOdd; if (sum > 0) std::cout << sum << std::endl; else std::cout << "NIESTETY" << 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 | #include <iostream> int main() { long long unsigned int n, v, sum=0, smalestOdd=1001; std::cin >> n; for (long long unsigned int i=0; i<n; i++) { std::cin >> v; sum+=v; if ((v%2) && (smalestOdd > v)) smalestOdd=v; } if (! (sum%2)) { std::cout << sum << std::endl; } else { sum-=smalestOdd; if (sum > 0) std::cout << sum << std::endl; else std::cout << "NIESTETY" << std::endl; } return 0; } |