【Codeforces Round #446 (Div. 2) B】Wrath
【链接】 我是链接,点我呀:)
【题意】
【题解】
倒着来,维护一个最小的点就可以了。【代码】
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
int a[N+10],n;
int isdead[N+10];
int main(){
#ifdef LOCAL_DEFINE
freopen("F:\\c++source\\rush_in.txt", "r", stdin);
#endif
scanf("%d",&n);
for (int i = 1;i <= n;i++)
scanf("%d",&a[i]);
reverse(a+1,a+1+n);
isdead[1] = 0;
int now = 1 + a[1];
for (int i = 2;i <= n;i++){
if (now>=i){
isdead[i] = 1;
}
now = max(now,i+a[i]);
}
int cnt = 0;
for (int i = 1;i <= n;i++)
if (!isdead[i]){
cnt++;
}
printf("%d\n",cnt);
return 0;
}