#P13261. [GCJ 2014 #3] Last Hit
[GCJ 2014 #3] Last Hit
题目描述
Diana needs your help maximizing her gold while playing her favorite game. She is often faced with a scenario where she is standing close to her tower and is facing monsters. When that happens, Diana and the tower take turns shooting the monsters, and she goes first. During her turn, Diana may choose a monster to shoot at (this means Diana may choose to skip a turn). During its turn, the tower shoots the monster closest to it. Diana and the tower can not shoot dead monsters.
If Diana shoots at a monster, its hit points are reduced by . If the tower shoots at a monster, its hit points are reduced by . If a monster's hit points are reduced below 1, it is killed. The monster starts with hit points. Diana is awarded gold if her shot kills the monster, but none if the tower's shot kills it. What is the maximum amount of gold Diana can obtain?
输入格式
The first line of the input gives the number of test cases, . test cases follow. Each case begins with one line containing three space-separated integers representing and . lines then follow, with the line containing two space-separated integers representing and .
The monsters are given in the order of their distance from the tower. In other words, the tower will shoot at the monster only if all monsters are dead.
输出格式
For each test case, output one line containing "Case #x: ", where x is the case number (starting from 1) and is the maximum amount of gold that Diana can obtain.
2
20 40 3
100 100
20 100
60 100
20 60 3
80 100
80 200
120 300
Case #1: 300
Case #2: 500
提示
Sample Explanation
In the second example, Diana should give up the first monster. During her first two turns she should soften up the third monster bringing it down to 80 hp, allowing her to easily get the last shot on the second and the third monsters.
Limits
Small dataset(10 Pts)
- Time limit:
603 seconds.
Large dataset(14 Pts)
- Time limit:
1205 seconds.