#P6531. Balloon Shooting
Balloon Shooting
Balloon Shooting
You are given n balloons, each with a height \(h_i\). An arrow can be shot at any height. When an arrow hits a balloon at height \(h\), the arrow bursts the balloon and its height immediately decreases by \(1\), continuing its flight at the new height to burst other balloons. Determine the minimum number of arrows that must be shot in order to burst all the balloons.
Note: The arrow can only burst a balloon if its current height exactly matches the balloon's height.
inputFormat
The first line contains an integer \(n\) representing the number of balloons. The second line contains \(n\) space-separated integers \(h_1, h_2, ..., h_n\) where \(h_i\) is the height of the \(i\)-th balloon.
outputFormat
Output a single integer representing the minimum number of arrows needed to burst all the balloons.
sample
5
3 2 1 5 4
2