Logo
(追記) (追記ここまで)

15456번 - Greedy Gift Takers 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB30013610748.416%

문제

Farmer John's nemesis, Farmer Nhoj, has $N$ cows (1ドル \leq N \leq 10^5$), conveniently numbered 1ドル \dots N$. They have unexpectedly turned up at Farmer John's farm, so the unfailingly polite Farmer John is attempting to give them gifts.

To this end, Farmer John has brought out his infinite supply of gifts, and Nhoj's cows have queued up in front of him, with cow 1ドル$ at the head of the queue and cow $N$ at the tail. Farmer John was expecting that at every timestep, the cow at the head of the queue would take a gift from Farmer John and go to the tail of the queue. However, he has just realized that Nhoj's cows are not that polite! After receiving her gift, each cow may not go to the tail of the queue, but rather may cut some number of cows at the tail, and insert herself in front of them. Specifically, cow $i$ will always cut exactly $c_i$ cows (0ドル \leq c_i \leq N-1$).

Farmer John knows that some cows might receive multiple gifts; as he has an infinite supply, this does not worry him. But he is worried that some cows might become unhappy if they do not get any gifts.

Help Farmer John find the number of cows who never receive any gifts, no matter how many gifts are handed out.

입력

The first line contains a single integer, $N$.

The second line contains $N$ space-separated integers $c_1, c_2, \dots, c_N$.

출력

Please output the number of cows who cannot receive any gifts.

제한

예제 입력 1

3
1 2 0

예제 출력 1

1

힌트

출처

Olympiad > USA Computing Olympiad > 2017-2018 Season > USACO 2017 December Contest > Platinum 3번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /