P29424 [洛谷] [COCI2015-2016#1] BALONI
普及
题目描述

Problem Background

The archer shoots balloons!

Problem Description

The archer needs to shoot down $n$ balloons, each with a given height, denoted as $h_i$.

The arrow will descend due to the elasticity of the balloons, and after hitting a balloon, the arrow's height will decrease by 1.

The archer can shoot arrows at any height.

Determine the minimum number of arrows the archer needs to shoot.

Input Format

The first line contains a single integer $n$.

The next line contains $n$ integers $h_i$.

Output Format

A single line containing one integer, representing the minimum number of arrows the archer needs to shoot.

Sample Input and Output

Sample Input #1

5
2 1 5 4 3

Sample Output #1

2

Sample Input #2

5
1 2 3 4 5

Sample Output #2

5

Sample Input #3

5
4 5 2 1 4

Sample Output #3

3

Notes

Sample 1 Explanation

First, shoot an arrow at height 5 to hit the balloon, then shoot an arrow at height 2 to hit the balloon.

Data Range and Constraints

  • For 40% of the data, it is guaranteed that $n \le 5 \times 10^3$.
  • For 100% of the data, it is guaranteed that $1 \le n, h_i \le 10^6$.

Notes

This problem is worth 100 points.

This problem is translated from the Croatian Open Competition in Informatics 2015/2016 Contest #1 T3 BALONI.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5 2 1 5 4 3
样例输出
2