문제
Bessie has
Bessie wants to minimize the total ugliness of the tiles, which is defined as the sum of the maximum ugliness over every consecutive pair of tiles; that is,
Determine the minimum possible total ugliness Bessie can achieve if she performs operations optimally.
입력
The first line contains
The next line contains
The next line contains the
출력
Output the minimum possible total ugliness.
부분문제
| 번호 | 점수 | 조건 |
|---|---|---|
| #1 | 10점 | |
| #2 | 20점 | |
| #3 | 30점 | |
| #4 | 40점 | 추가 제약 조건 없음 |
예제
3 0
1 100 10
110
Bessie can swap the second and third tiles so that