##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
| # | Title | Points | Solved | Admin | |
|---|---|---|---|---|---|
You are given an array of length .
Before performing any operations, choose a non-negative integer . Then, you may perform the following operation any number of times:
Find the minimum value of for which it is possible to sort the array in non-decreasing order.
The input consists of two lines:
Output one integer, the minimum possible value of .
With , one possible sequence is
.
A value smaller than does not allow and to swap, although their order must change. Therefore, the minimum value is .
The array is already sorted, so no operation is needed. We may choose .
With , the array can be sorted as follows:
.
If , the elements and cannot swap, so they cannot reach their required order. Thus, the answer is .