CF892B.Wrath
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
沾满无辜者鲜血的双手!
一排中有 n 个有罪之人,其中第 i 个人手持一把长度为 Li 的利爪。铃声响起,每个人同时杀死自己前方的一些人。具体而言,第 i 个人杀死第 j 个人,当且仅当 j<i 且 j≥i−Li。
你将获得所有利爪的长度。你需要求出铃声响起后仍然存活的人数总数。
输入格式
The first line contains one integer n (1 ≤ n ≤ 106) — the number of guilty people.
Second line contains n space-separated integers _L_1, _L_2, ..., L__n (0 ≤ L__i ≤ 109), where L__i is the length of the i-th person's claw.
第一行包含一个整数 n(1≤n≤106)——有罪之人的数量。
第二行包含 n 个用空格分隔的整数 L1,L2,…,Ln(0≤Li≤109),其中 Li 表示第 i 个人的爪子长度。
输出格式
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.
在第一个样例中,最后一个人杀死了他前面的所有人。
输入解题思路,AI测评打分。不知道怎么写?