CF892.B. Wrath

时间:2023-03-09 00:22:52
CF892.B. Wrath

---恢复内容开始---

###题意:
有n个犯人,手上都有个长度为Li的武器,当铃响时大家同时挥动武器,只能把前面攻击范围内的敌人杀死,问最后还剩几个人。
![](https://images2018.cnblogs.com/blog/1342501/201807/1342501-20180727200740562-1624391818.png)
###题目传送门:
[http://codeforces.com/contest/892/problem/B]
###思路:
从后面遍历能杀的人,一个一个杀,更新当前能杀的最大人数,用sum统计,最后输出n-sum即可。
###代码:
```
#include
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,i;
int a[1000005];
while(cin>>n){
for(i=1;i>a[i];
int sum=0,can=a[n];
for(i=n-1;i>0;i--){
if(can)
sum++;
can--;
can=max(can,a[i]);
}
cout