#include <iostream> const std::string NIESTETY = "NIESTETY"; long n; int theLowestOddBill, bill, sum = 0; int main(int argc, char const *argv[]) { theLowestOddBill = 1001; std::cin >> n; for(int i = 0; i < n; ++i) { std::cin >> bill; sum += bill; if (bill%2) { if (bill < theLowestOddBill) { theLowestOddBill = bill; } } } if (sum%2) { if ((theLowestOddBill < 1001) && (sum > theLowestOddBill)) { std::cout << (sum - theLowestOddBill); } else { std::cout << NIESTETY; } } else { std::cout << sum; } 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 | #include <iostream> const std::string NIESTETY = "NIESTETY"; long n; int theLowestOddBill, bill, sum = 0; int main(int argc, char const *argv[]) { theLowestOddBill = 1001; std::cin >> n; for(int i = 0; i < n; ++i) { std::cin >> bill; sum += bill; if (bill%2) { if (bill < theLowestOddBill) { theLowestOddBill = bill; } } } if (sum%2) { if ((theLowestOddBill < 1001) && (sum > theLowestOddBill)) { std::cout << (sum - theLowestOddBill); } else { std::cout << NIESTETY; } } else { std::cout << sum; } return 0; } |