Logo
(追記) (追記ここまで)

23119번 - Deleting 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 512 MB38141348.148%

문제

You are given an array $[1, 2, \ldots, n],ドル where the number of elements $n$ is even.

In one operation, you can delete two adjacent elements of the array. If these elements are $i$ and $j,ドル the cost of this operation is $\mathit{cost}(i, j)$.

In $\frac{n}{2}$ operations, all elements will be deleted. The cost of deleting the whole array is defined as the largest cost among all the $\frac{n}{2}$ operations.

What is the smallest possible cost of deleting the whole array?

입력

The first line of the input contains a single integer $n$ (2ドル \le n \le 4000,ドル $n$ is even).

We are kind today. So we won't provide unnecessary input. It can be shown that it's impossible for two numbers of the same parity to be adjacent at any point, so we won't provide costs for those pairs.

The $i$-th of the next $n - 1$ lines contains $\lfloor \frac{n-i+1}{2} \rfloor$ integers. If $i$ is even, these integers are $\mathit{cost}(i, i+1), \mathit{cost}(i, i+3), \ldots, \mathit{cost}(i, n-1)$. Otherwise, they are $\mathit{cost}(i, i+1), \mathit{cost}(i, i+3), \ldots, \mathit{cost}(i, n)$.

It is guaranteed that the costs form a permutation of numbers from 1ドル$ to $(\frac{n}{2} )^2$.

출력

Output a single integer: the smallest possible cost of deleting the whole array.

제한

예제 입력 1

2
1

예제 출력 1

1

예제 입력 2

6
2 1 3
4 5
6 7
8
9

예제 출력 2

6

예제 입력 3

10
20 21 2 11 25
3 24 18 8
6 17 7 5
22 4 23
14 15 1
19 16
12 10
13
9

예제 출력 3

14

힌트

In the first example, the array is $[1, 2],ドル and $\mathit{cost}(1, 2) = 1$. So, the only way to delete the array has the total cost of 1ドル$.

In the second example, one of the ways to delete the array is:

  • $[1, 2, 3, 4, 5, 6] \to [1, 2, 5, 6],ドル deleting pair $(3, 4)$ with cost 6ドル$.
  • $[1, 2, 5, 6] \to [1, 6],ドル deleting pair $(2, 5)$ with cost 5ドル$.
  • And then deleting pair $(1, 6)$ with cost 3ドル$.

The total cost is therefore $\max (6, 5, 3) = 6$.

출처

Camp > Petrozavodsk Programming Camp > Summer 2021 > Day 3: IQ test by kefaa2, antontrygubO_o, and gepardo D번

Contest > Open Cup > 2021/2022 Season > Stage 2: Grand Prix of IMO D번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /