测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A11413. Wrath

编程题 普及/提高-

题目描述

Hands that shed innocent blood!

There are $n$ guilty people in a line, the $i$ -th of them holds a claw with length $L_{i}$ . The bell rings and every person kills some of people in front of him. All people kill others at the same time. Namely, the $i$ -th person kills the $j$ -th person if and only if $j<i$ and $j>=i-L_{i}$ .

You are given lengths of the claws. You need to find the total number of alive people after the bell rings.

输入格式

The first line contains one integer $n$ ( $1<=n<=10^{6}$ ) — the number of guilty people.

Second line contains $n$ space-separated integers $L_{1},L_{2},...,L_{n}$ ( $0<=L_{i}<=10^{9}$ ), where $L_{i}$ is the length of the $i$ -th person's claw.

输出格式

Print one integer — the total number of alive people after the bell rings.

输入输出样例

输入 #1
4
0 1 0 10
输出 #1
1
输入 #2
2
0 0
输出 #2
2
输入 #3
10
1 1 3 0 0 0 2 1 0 3
输出 #3
3

说明/提示

In first sample the last person kills everyone in front of him.
上一题 去做题 下一题