1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
	int a, b, c, m = 2019, x;
	scanf("%d%d", &a, &b);
	for(int i = 0; i < a; ++i){
		for(int j = 0; j < i + 1; ++j){
			scanf("%d", &c);
			x = min(j, i - j);
			if((i < 2 * x + 1 && (x + 1) * (x + 1) <= b) || (i == 2 * x + 1 && (x + 1) * (x + 2) <= b) || (i > 2 * x + 1 && (x + 1) * (x + 2) + (x + 1) * (i - 2 * x - 1) <= b)){
				m = min(m, c);
			}
		}
	}
	printf("%d", m);
}