CF1763B.Incinerate
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
To destroy humanity, The Monster Association sent n monsters to Earth's surface. The i-th monster has health hi and power pi.
With his last resort attack, True Spiral Incineration Cannon, Genos can deal k damage to all monsters alive. In other words, Genos can reduce the health of all monsters by k (if k>0) with a single attack.
However, after every attack Genos makes, the monsters advance. With their combined efforts, they reduce Genos' attack damage by the power of the †weakest monster ‡alive. In other words, the minimum pi among all currently living monsters is subtracted from the value of k after each attack.
†The Weakest monster is the one with the least power.
‡A monster is alive if its health is strictly greater than 0.
Will Genos be successful in killing all the monsters?
为了毁灭人类,怪人协会向地球表面派遣了 n 只怪人。第 i 只怪人的生命值为 hi,力量值为 pi。
金木研使用其最终奥义——“真·螺旋焚灭炮”,可对所有现存怪人造成 k 点伤害。换言之,金木研单次攻击可将所有现存怪人的生命值同时减少 k(若 k>0)。
然而,金木研每次发动攻击后,怪人们便会协同进化并削弱金木研的攻击力——削弱量等于当前所有存活怪人中力量值最小者的力量值。换言之,每次攻击后,k 的值将减去当前所有存活怪人中最小的 pi 值。
†所谓“最弱怪人”,即力量值 pi 最小的怪人。
‡一只怪人被视为“存活”,当且仅当其生命值严格大于 0。
金木研能否成功消灭所有怪人?
输入格式
The first line of the input contains a single integer t (1≤t≤100) — the number of test cases. The description of test cases follows.
The first line of each test case contains two integers, n and k (1≤n,k≤105) — the number of monsters and Genos' initial attack damage. Then two lines follow, each containing n integers describing the arrays h and p (1≤hi,pi≤109).
It's guaranteed that the sum of n over all test cases does not exceed 2⋅105.
输入的第一行包含一个整数 t(1≤t≤100),表示测试用例的数量。随后是各测试用例的描述。
每个测试用例的第一行包含两个整数 n 和 k(1≤n,k≤105),分别表示怪物数量和 Genos 的初始攻击力。接下来两行,每行包含 n 个整数,分别描述数组 h 和 p(1≤hi,pi≤109)。
保证所有测试用例中 n 的总和不超过 2⋅105。
输出格式
For each test case, print the answer — "YES" (without quotes) if Genos could kill all monsters and "NO" otherwise.
对于每个测试用例,输出答案——如果 Genos 能够杀死所有怪物,则输出 "YES"(不带引号),否则输出 "NO"。
输入输出样例
输入#1
3 6 7 18 5 13 9 10 1 2 7 2 1 2 6 3 4 5 5 5 4 4 4 3 2 2 1 3 1 1 1
输出#1
YES NO YES
说明/提示
In the first example, after Genos' first attack, h and k will update to:
- h:[11,0,6,2,3,0]
- k:7−1=6
After second attack:
- h:[5,0,0,0,0,0]
- k:6−2=4
After third attack:
- h:[1,0,0,0,0,0]
- k:4−2=2
After fourth attack:
- h:[0,0,0,0,0,0]
As Genos could kill all monsters, the answer is YES.
在第一个例子中,Genos 第一次攻击后,h 和 k 将更新为:
- h:[11,0,6,2,3,0]
- k:7−1=6
第二次攻击后:
- h:[5,0,0,0,0,0]
- k:6−2=4
第三次攻击后:
- h:[1,0,0,0,0,0]
- k:4−2=2
第四次攻击后:
- h:[0,0,0,0,0,0]
由于 Genos 能够消灭所有怪物,答案为 YES。
输入解题思路,AI测评打分。不知道怎么写?