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
#include<cstdio>
using namespace std;

int n, d, k;

int main(){
	scanf("%d %d", &n, &d);
	
	int foundMin = 2020;
	
	
	for (int i = 0; i < n; ++i) {
		int baseDepth = i+1;
		int currentDepth = 0;
		for (int j = 0; j <= i; ++j) {
			currentDepth += baseDepth;
			baseDepth -= 2;
			scanf("%d", &k);
			if (currentDepth <= d && k < foundMin) {
				foundMin = k;
			}
		}
	}
	
	printf("%d\n", foundMin);
	return 0;
}