#include <iostream> #include <algorithm> using namespace std; const int KMax = 1000005; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int a; std::cin >> a; int parzyste = 0; int nieparzyste = 0; int minn = KMax; for (int x = 0; x < a; ++x) { int b; std::cin >> b; if (!(b % 2)) { parzyste += b; } else { minn = std::min(minn, b); nieparzyste += b; } } int result = parzyste + nieparzyste; if (nieparzyste % 2 == 0) { std::cout << result; } else { if (result - minn == 0) { std::cout << "NIESTETY"; } else { std::cout << result - minn; } } 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 | #include <iostream> #include <algorithm> using namespace std; const int KMax = 1000005; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int a; std::cin >> a; int parzyste = 0; int nieparzyste = 0; int minn = KMax; for (int x = 0; x < a; ++x) { int b; std::cin >> b; if (!(b % 2)) { parzyste += b; } else { minn = std::min(minn, b); nieparzyste += b; } } int result = parzyste + nieparzyste; if (nieparzyste % 2 == 0) { std::cout << result; } else { if (result - minn == 0) { std::cout << "NIESTETY"; } else { std::cout << result - minn; } } return 0; } |