| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 20 초 (추가 시간 없음) | 1024 MB | 21 | 12 | 10 | 62.500% |
Your team is about to prove itself in a dance battle! Initially, your team has E points of energy, and zero points of honor. There are N rival teams who you must face; the i-th of these teams is the i-th in a lineup, and has a dancing skill of Si.
In each round of battle, you will face the next rival team in the lineup, and you can take one of the following actions:
The battle is over when there are no more rival teams in the lineup. If you make optimal decisions, what is the maximum amount of honor you can have when the battle is over?
The first line of the input gives the number of test cases, T. T test cases follow; each consists of two lines. The first line consists of two integers E and N: your team's energy, and the number of rival teams. The second line consists of N integers Si; the i-th of these represents the dancing skill of the rival team that is i-th in line at the start of the battle.
For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the maximum amount of honor you can have when the battle is over.
2 100 1 100 10 3 20 3 15
Case #1: 0 Case #2: 1
In Sample Case #1, there is only one rival team. You cannot dance against them because it would make your energy fall to 0, and you cannot recruit them because it would make your honor fall below 0. Delaying does not help, so the only option is to declare a truce. You finish with 0 honor.
In Sample Case #2, one optimal strategy is:
You finish with 1 point of honor.
Contest > Google > Kick Start > Google Kick Start 2017 > Round F C번