A Difficult(y) Choice
문제
Immortal glory goes to those who win a medal at BOI. As you are keen on being one of them, this is your way to go*: training, training, training!
As a first step in your training program, you decided to buy some computer science books. Luckily, your local book store has a special offer with a hefty discount when you buy exactly books.
Now you are to select the books to buy from the set of computer science books (numbered 1 to ) offered in the book store. Your key selection factor is difficulty: Each book has an individual (and fully objective) difficulty , and the total difficulty of a set of books is the sum of their individual difficulties. You don’t want the selected books to be too easy (then you wouldn’t learn enough to win that precious medal) or too difficult (then you wouldn’t understand them before the contest starts). To be precise, you want the total difficulty of the selected books to be at least , but not more than .
Judging the actual difficulty of a book requires you to skim through it, but the store owner won’t be happy if you read many books without buying them. She allows you to skim through at most books. Fortunately, she also tells you that the books are sorted by increasing difficulty.
Write a program that assists you in deciding on which books to skim through, and in the end tells you which books to buy.
* “Is it, really?,” says a tiny voice in your head…