#1215
Unrated
BALONI
시간 제한
2s
메모리 제한
128MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Author: Dominik Gleich

There are N balloons floating in the air in a large room, lined up from left to right. Young Perica likes to play with arrows and practice his hunting abilities. He shoots an arrow from the left to the right side of the room from an arbitrary height he chooses. The arrow moves from left to right, at a chosen height H until it finds a balloon. The moment when an arrow touches a balloon, the balloon pops and disappears and the arrow continues its way from left to right at a height decreased by 1. Therefore, if the arrow was moving at height H, after popping the balloon it travels on height H-1. Our hero’s goal is to pop all the balloons using as little arrows as possible.

입력

The first line of input contains the integer N (1 ≤ N ≤ 1 000 000). The second line of input contains an array of N integers Hi. Each integer Hi (1 ≤ Hi ≤ 1 000 000) is the height at which the ith balloon floats, respectively from left to right.

출력

The first and only line of output must contain the minimal number of times Pero needs to shoot an arrow so that all balloons are popped.

예제 입력 1

5
2 1 5 4 3

예제 출력 1

2

예제 입력 2

5
1 2 3 4 5

예제 출력 2

5

예제 입력 3

5
4 5 2 1 4

예제 출력 3

3
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.