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
#include <cstdio>
#include <vector>
using namespace std;

int main() {
	int n, k, i, j, a;
	scanf("%d%d", &n, &k);
	vector<vector<int>> sum(n, vector<int>(n, 0));
	int mi = 10000000;
	for (i = 0; i < n; ++i) {
		for (j = 0; j <= i; ++j) {
			scanf("%d", &a);
			sum[i][j] = 1;
			if (i >= 1 && j >= 1)
				sum[i][j] += sum[i - 1][j - 1];
			if (i >= 1)
				sum[i][j] += sum[i - 1][j];
			if (i >= 2 && j >= 1)
				sum[i][j] -= sum[i - 2][j - 1];
			if (sum[i][j] <= k)
				mi = min(mi, a);
		}
	}
	printf("%d", mi);
	return 0;
}