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

using namespace std;

typedef long long int LL;

const int N = 2007;

int n, k;
int all[N][N];
int Right[N][N];

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