PivotOJ

A Difficult(y) Choice

시간 제한: 1000ms메모리 제한: 512MB출처: BOI 2021BOJ 21845

문제

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 KK books.

Now you are to select the KK books to buy from the set of NN computer science books (numbered 1 to NN) offered in the book store. Your key selection factor is difficulty: Each book ii has an individual (and fully objective) difficulty xix_i, 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 AA, but not more than 2A2A.

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 SS 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…

코드를 제출하려면 로그인하세요.