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
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 2005;

int n, k;
vector<int> wina[MAXN];
vector<int> DP[MAXN];

int main()
{
	scanf("%d%d", &n, &k);
	int res = 1e9;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j < i; j++) {
			int a;
			scanf("%d", &a);
			wina[i].push_back(a);
			if(i == 1)
				DP[i].push_back(1);
			else if(j == 0)
				DP[i].push_back(DP[i-1][0] + 1);
			else if(j == i - 1)
				DP[i].push_back(DP[i-1][j-1] + 1);
			else
				DP[i].push_back(DP[i-1][j-1] + DP[i-1][j] - DP[i-2][j-1] + 1);
			if(DP[i][j] <= k)
				res = min(res, wina[i][j]);
//			printf("%d ", DP[i][j]);
		}
//		printf("\n");
	}
	printf("%d", res);
}