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
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
 
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n, k;
	int ans = 3000;
	cin >> n >> k;
	vector<vector<int>> dp(n + 10, vector<int>(n + 10));
	dp[1][1] = 1;
	for (int a = 1; a <= n; a++) {
		for (int b = 1; b <= a; b++) {
			int x;
			cin >> x;
			if (a > 1 && b != a) {
				dp[a][b] = dp[a - 1][b - 1] + dp[a - 1][b] - dp[a - 2][b - 1] + 1;
			} else if (a > 1) {
				dp[a][b] = dp[a - 1][b - 1] + 1;
			}
			if (dp[a][b] <= k) ans = min(ans, x);
		}
	}

	cout << ans << endl;

 
	return 0;
}