CF1633C.Kill the Monster

普及/提高-

通过率:0%

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 hCh_C and attack dCd_C ; the monster initially has health hMh_M and attack dMd_M . The fight consists of several steps:

  1. the character attacks the monster, decreasing the monster's health by dCd_C ;
  2. the monster attacks the character, decreasing the character's health by dMd_M ;
  3. the character attacks the monster, decreasing the monster's health by dCd_C ;
  4. the monster attacks the character, decreasing the character's health by dMd_M ;
  5. and so on, until the end of the fight.

The fight ends when someone's health becomes non-positive (i. e. 00 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 hCh_C and attack equal to dCd_C . He wants to slay a monster with health equal to hMh_M and attack equal to dMd_M . Before the fight, Monocarp can spend up to kk 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 ww , and each armor upgrade increases the character's health by aa .

Can Monocarp's character slay the monster if Monocarp spends coins on upgrades optimally?

输入格式

The first line contains one integer tt ( 1t51041 \le t \le 5 \cdot 10^4 ) — the number of test cases. Each test case consists of three lines:

The first line contains two integers hCh_C and dCd_C ( 1hC10151 \le h_C \le 10^{15} ; 1dC1091 \le d_C \le 10^9 ) — the character's health and attack;

The second line contains two integers hMh_M and dMd_M ( 1hM10151 \le h_M \le 10^{15} ; 1dM1091 \le d_M \le 10^9 ) — the monster's health and attack;

The third line contains three integers kk , ww and aa ( 0k21050 \le k \le 2 \cdot 10^5 ; 0w1040 \le w \le 10^4 ; 0a10100 \le a \le 10^{10} ) — 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 kk over all test cases does not exceed 21052 \cdot 10^5 .

输出格式

For each test case, print YES if it is possible to slay the monster by optimally choosing the upgrades. Otherwise, print 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 55 ), then health during battle will change as follows: (hC,hM)=(25,9)(25,4)(5,4)(5,1)(h_C, h_M) = (25, 9) \rightarrow (25, 4) \rightarrow (5, 4) \rightarrow (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 44 coins. To defeat the monster, he has to spend 22 coins to upgrade weapon and 22 coins to upgrade armor.

首页