1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <bits/stdc++.h>

using namespace std;


typedef long long LL;


const int MAXN = 2048;
const int INF = 1 << 30;


int dp[MAXN][MAXN];


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n, k;
	cin >> n >> k;

	int res = INF;

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j <= i; ++j) {
			int a;
			cin >> a;
			
			int c = i - j + 1;
			int p = (j > 0 ? dp[i - 1][j - 1] : 0);

			dp[i][j] = c + p;

			if (k >= c + p)
				res = min(res, a);
		}
	}

	cout << res << endl;

	return 0;
}