1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#include <bits/stdc++.h>

using namespace std;

int n,k,a,d[2002][2002],w=2020;

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