Loading...
Loading...
Loading...
Students stand in a row, each with a rating. Every student gets at least 1 reward point, and a student with a higher rating than a neighbour must get more points than that neighbour. Print the smallest total number of points.
Example 1
Input
1 0 2
Output
5
Example 2
Input
1 2 2
Output
4
Try the problem first. Open one hint at a time.
Handle the left neighbour and the right neighbour in two separate passes.
Pass left to right raising points when the rating grows. Then pass right to left and take the larger of the two values.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor