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
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
int dp[1010][1010];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,k,w,a,i,j;
	cin>>n>>k;
	dp[1][1]=1;
	cin>>w;
	for(i=2;i<=n;i++)
	{
		for(j=1;j<=i;j++)
		{
			cin>>a;
			dp[i][j]=dp[i-1][j]+dp[i-1][j-1]-dp[i-2][j-1]+1;
			if(dp[i][j]<=k)
				w=min(w,a);
		}
	}
	cout<<w<<"\n";
	return 0;
}