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

int T[4000010], N, K[2020][2020], it=1, k, n, res=2020;
int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin>>n>>k;
	
	N = (n * (n+1))/2;
	
	for(int i=1;i<=N;i++)
		cin>>T[i];
		
	K[1][1]=1;
	res = min(res, T[it]);
	
	for(int i = 2 ; i<=n; i++){
		for(int j = 1; j<=i;j++){
		 	it++;		 		
			K[i][j] = K[i-1][j]+K[i-1][j-1]-K[i-2][j-1]+1;	
			if(K[i][j]<=k)
				res=min(res,T[it]);
		}
	}
	cout<<res<<endl;
}