Vanya and Fence
Practice this coding question on Coding Gurukul.
Problem statement
Students walk past a fence. A student no taller than the fence uses one unit of horizontal space; a taller student bends and uses two units. Calculate the total space required when everyone walks side by side.
Input format
First line: n h. Second line: n heights.
Output format
Print the total width.
Constraints
1 <= n,h <= 1000; 1 <= height <= 2h.
Sample input
4 5 3 5 6 9
Sample output
6
Sign in to run or submit a solution in C++, Java or Python.