A15492 | Incinerate
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
To destroy humanity, The Monster Association sent $n$ monsters to Earth's surface. The $i$ -th monster has health $h_i$ and power $p_i$ .
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 $^\dagger$ weakest monster $^\ddagger$ alive. In other words, the minimum $p_i$ among all currently living monsters is subtracted from the value of $k$ after each attack.
$^\dagger$ The Weakest monster is the one with the least power.
$^\ddagger$ A monster is alive if its health is strictly greater than $0$ .
Will Genos be successful in killing all the monsters?
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 $^\dagger$ weakest monster $^\ddagger$ alive. In other words, the minimum $p_i$ among all currently living monsters is subtracted from the value of $k$ after each attack.
$^\dagger$ The Weakest monster is the one with the least power.
$^\ddagger$ A monster is alive if its health is strictly greater than $0$ .
Will Genos be successful in killing all the monsters?
输入格式
The first line of the input contains a single integer $t$ ( $1 \le t \le 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 \le n, k \le 10^5$ ) — the number of monsters and Genos' initial attack damage. Then two lines follow, each containing $n$ integers describing the arrays $h$ and $p$ ( $1 \le h_i, p_i \le 10^9$ ).
It's guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$ .
The first line of each test case contains two integers, $n$ and $k$ ( $1 \le n, k \le 10^5$ ) — the number of monsters and Genos' initial attack damage. Then two lines follow, each containing $n$ integers describing the arrays $h$ and $p$ ( $1 \le h_i, p_i \le 10^9$ ).
It's guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$ .
输出格式
For each test case, print the answer — "YES" (without quotes) if Genos could kill all monsters and "NO" otherwise.
输入输出样例
输入 #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.
- $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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted