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
33
34
35
36
37
38
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); ++i)
#define mp make_pair
#define pb push_back
#define st first
#define nd second

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

const int maxn = 2005;
const int inf = 5000;
int t[maxn][maxn];

void solve() {
	int n, k; cin>>n>>k;
	int best =inf;
	for(int i=n-1; i>=0; --i) for(int j=0; j<n-i; ++j) {
		int x; cin>>x;
		t[i][j]=n-i;
		if(i+2<=n-1 && j-1>=0) t[i][j]+=t[i+2][j-1];
		if(t[i][j]<=k) best=min(best, x);
	}
	assert(best<inf);
	cout<<best<<"\n";
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	//cin>>t;
	while(t--) solve();
	return 0;
}