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

using namespace std;

int n, k, ans = 3000, amarena;

bool f(int i, int pos)
{
	int all = i * (i + 1) / 2, l = pos * (pos - 1) / 2, r = (i - n) * (i - n + 1) / 2;
	if(k >= all - (l + r)) return true;
	return false;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin>>n>>k;
	for(int i = 1; i <= n; i++) {
		for(int pos = 1; pos <= i; pos++) {
			cin>>amarena;
			if(f(i,pos)) ans = min(ans, amarena);
		}
	}
	cout<<ans;
	return 0;
}