문제
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
코드를 제출하려면 로그인이 필요합니다.
로그인