CF1633C.Kill the Monster
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Monocarp is playing a computer game. In this game, his character fights different monsters.
A fight between a character and a monster goes as follows. Suppose the character initially has health hC and attack dC; the monster initially has health hM and attack dM. The fight consists of several steps:
- the character attacks the monster, decreasing the monster's health by dC;
- the monster attacks the character, decreasing the character's health by dM;
- the character attacks the monster, decreasing the monster's health by dC;
- the monster attacks the character, decreasing the character's health by dM;
- and so on, until the end of the fight.
The fight ends when someone's health becomes non-positive (i. e. 0 or less). If the monster's health becomes non-positive, the character wins, otherwise the monster wins.
Monocarp's character currently has health equal to hC and attack equal to dC. He wants to slay a monster with health equal to hM and attack equal to dM. Before the fight, Monocarp can spend up to k coins to upgrade his character's weapon and/or armor; each upgrade costs exactly one coin, each weapon upgrade increases the character's attack by w, and each armor upgrade increases the character's health by a.
Can Monocarp's character slay the monster if Monocarp spends coins on upgrades optimally?
Monocarp 正在玩一款电脑游戏。在游戏中,他的角色会与各种怪物战斗。
角色与怪物之间的战斗过程如下:假设角色初始生命值为 hC、攻击力为 dC;怪物初始生命值为 hM、攻击力为 dM。战斗由若干轮步骤组成:
- 角色攻击怪物,使怪物生命值减少 dC;
- 怪物攻击角色,使角色生命值减少 dM;
- 角色攻击怪物,使怪物生命值减少 dC;
- 怪物攻击角色,使角色生命值减少 dM;
- 如此反复,直至战斗结束。
当某一方的生命值变为非正值(即 ≤0)时,战斗结束。若怪物生命值首先变为非正值,则角色获胜;否则怪物获胜。
Monocarp 的角色当前生命值为 hC、攻击力为 dC。他希望击败一只生命值为 hM、攻击力为 dM 的怪物。在战斗开始前,Monocarp 最多可花费 k 枚金币来升级角色的武器和/或护甲;每次升级恰好花费 1 枚金币,每次武器升级使角色攻击力增加 w,每次护甲升级使角色生命值增加 a。
如果 Monocarp 能够以最优方式分配金币进行升级,他的角色能否成功击败该怪物?
输入格式
The first line contains one integer t (1≤t≤5⋅104) — the number of test cases. Each test case consists of three lines:
The first line contains two integers hC and dC (1≤hC≤1015; 1≤dC≤109) — the character's health and attack;
The second line contains two integers hM and dM (1≤hM≤1015; 1≤dM≤109) — the monster's health and attack;
The third line contains three integers k, w and a (0≤k≤2⋅105; 0≤w≤104; 0≤a≤1010) — the maximum number of coins that Monocarp can spend, the amount added to the character's attack with each weapon upgrade, and the amount added to the character's health with each armor upgrade, respectively.
The sum of k over all test cases does not exceed 2⋅105.
第一行包含一个整数 t(1≤t≤5⋅104),表示测试用例的数量。每个测试用例由三行组成:
第一行包含两个整数 hC 和 dC(1≤hC≤1015;1≤dC≤109),分别表示角色的生命值和攻击力;
第二行包含两个整数 hM 和 dM(1≤hM≤1015;1≤dM≤109),分别表示怪物的生命值和攻击力;
第三行包含三个整数 k、w 和 a(0≤k≤2⋅105;0≤w≤104;0≤a≤1010),分别表示 Monocarp 最多可花费的金币数量、每次武器升级所增加的角色攻击力、以及每次护甲升级所增加的角色生命值。
所有测试用例中 k 的总和不超过 2⋅105。
输出格式
For each test case, print YES if it is possible to slay the monster by optimally choosing the upgrades. Otherwise, print NO.
对于每个测试用例,如果可以通过最优地选择升级来击败怪物,则输出 YES;否则输出 NO。
输入输出样例
输入#1
4 25 4 9 20 1 1 10 25 4 12 20 1 1 10 100 1 45 2 0 4 10 9 2 69 2 4 2 7
输出#1
YES NO YES YES
说明/提示
In the first example, Monocarp can spend one coin to upgrade weapon (damage will be equal to 5), then health during battle will change as follows: (hC,hM)=(25,9)→(25,4)→(5,4)→(5,−1). The battle ended with Monocarp's victory.
In the second example, Monocarp has no way to defeat the monster.
In the third example, Monocarp has no coins, so he can't buy upgrades. However, the initial characteristics are enough for Monocarp to win.
In the fourth example, Monocarp has 4 coins. To defeat the monster, he has to spend 2 coins to upgrade weapon and 2 coins to upgrade armor.
在第一个例子中,Monocarp 可以花费 1 枚金币升级武器(伤害将变为 5),则战斗过程中的生命值变化如下:(hC,hM)=(25,9)→(25,4)→(5,4)→(5,−1)。此战以 Monocarp 的胜利告终。
在第二个例子中,Monocarp 无法击败该怪物。
在第三个例子中,Monocarp 没有金币,因此无法购买任何升级。但其初始属性已足以使 Monocarp 获胜。
在第四个例子中,Monocarp 拥有 4 枚金币。为击败该怪物,他需花费 2 枚金币升级武器,另花费 2 枚金币升级护甲。
输入解题思路,AI测评打分。不知道怎么写?