Codeforces Round #700 (Div. 2) B. The Great Hero
https://codeforces.com/contest/1480/problem/B
最后杀哪个怪?
当然是最后杀攻击最高的怪。
因为杀了这个怪可能就同归了,如果先杀攻击高的怪,可能其他小怪还没杀就和这个大怪同归了。
最后一刀给攻击最高的怪,如何计算最后一刀之前英雄血量的状态呢?
相当于先打败所有怪,再把最后一刀掉的血加上(加上一个最高伤害)
最后一刀之前,只有英雄还活着,它就能杀出这最后一刀,即为杀死所有的小怪。
// // Created by w on 2021-02-08. // #include <iostream> #include <algorithm> #include <cstring> typedef long long ll ; struct gs //怪兽 { ll a,b; }ggs[100010]; using namespace std; int main() { ll N; cin>>N; while (N--) { ll A,B,n; cin>>A>>B>>n; ll maxsh = 0; for (int i = 0; i < n; ++i) { cin>>ggs[i].a; maxsh=max(maxsh,ggs[i].a); } for (int i = 0; i < n; ++i) { cin>>ggs[i].b; } for (int i = 0; i <n ; ++i) { //times是需要攻击小怪兽的次数 ll times=ggs[i].b/A+(ggs[i].b%A!=0); /*times 首先times=ggs[i].b/A是向下取整 接下来如果(ggs[i].b % A != 0),则括号里为true(1),正好为向上取整 */ B-=times*ggs[i].a; } B+=maxsh;//恢复到最后一刀之前的状态进行判断 if(B<=0)//最后一刀之前血量为0,坎不出最后一刀 puts("NO"); else//否则能砍出最后一刀 puts("YES"); } return 0; }

浙公网安备 33010602011771号