Mountain (mountain)

24 teams scored 2400 points on this task, for a maximum score of 100, an average score of 100 and a median score of 100.

Highlights

  1. Banfi, Vimercate is the institute with the most points (200).
  2. Lombardia is the region with the most points (600).

Statement

Given an array P, which is initially a permutation of the numbers 0, 1, …, N - 1. You can do the remove a valley operation on P: (1) select an index i (0 < i < |P| - 1) such that P_i < P_i - 1 and P_i < P_i + 1. (2) then, remove P_i from P. where |P| is the number of elements of the array P (which is initially N). Notice that after performing the operation, the number of elements of P will decrease by 1. Find the minimum number of times you need to remove a valley such that P becomes a mountain, i.e. firstly increasing, and then decreasing. Formally: there should exist an i such that 0 < i < |P| - 1 and P_j < P_j + 1 for each j < i and P_k - 1 > P_k for each k > i).