| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 4 초 | 2048 MB | 8 | 4 | 3 | 75.000% |
The members of the No-Weather-too-Extreme Recreational Climbing society completed their 200ドル$th successful summit today! To commemorate the occasion, you will take a picture of all the members standing together in one row.
After the photo for the 100ドル$th summit eight years ago turned into a moderate fiasco, you are determined to get things right this time and make sure that people are arranged in an aesthetically pleasing way before taking the photo.
As this group is all about climbing mountains, you want the heights of the climbers in the photo to make the shape of a mountain. More precisely, the climbers should be arranged such that their heights are first increasing and then decreasing (the increasing or decreasing part is allowed to be empty). The heights of all climbers are pairwise distinct, so for simplicity we will say that the shortest climber has height 1ドル,ドル the second-shortest climber has height 2ドル,ドル and so on.
The climbers have already positioned themselves in a row in some arbitrary way that is not necessarily visually pleasing. You will select a subset of the climbers and rearrange their positions among themselves, with all other climbers staying exactly where they are. To keep chaos to a minimum, you want the number of moving climbers to be as small as possible.
What is the size of the smallest subset of climbers such that it is possible to reorder them so that the sequence of heights becomes first increasing and then decreasing?
The input consists of:
Output the minimum number of climbers who need to move.
6 1 6 4 3 2 5
2
Swapping the first and the last climber is the optimal way to make the sequence of heights first increasing and then decreasing.
5 4 3 2 1 5
4
4 1 2 4 3
0
10 1 2 7 4 5 6 3 8 9 10
2
ICPC > Regionals > Europe > Northwestern European Regional Contest > NWERC 2025 G번