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
39
40
41
42
43
44
45
46
47
#include<iostream>
#include<assert.h>
#include<cstdio>
#include<string>
#include<cmath>
#include<bitset>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<utility>
using namespace std;

std::vector<int> FillRow(int row_nr) {
	std::vector<int> row;
	int needed = row_nr;
	int v = row_nr - 1;
	for (int i = 0; i < (row_nr + 2) / 2; i++) {
		row.push_back(needed);
		needed += v;
		v -= 2;
	}
	return row;
}

int SolveTestCase() {
	int n, k;
	std::cin >> n >> k;
	int result = 2019;
	for (int row = 0; row < n; row++) {
		auto needed = FillRow(row);
		for (int col = 0; col <= row; ++col) {
			int age;
			std::cin >> age;
			if (needed[std::min(col, row - col)] < k) {
				result = std::min(result, age);
			}
		}	
	}
	return result;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cout << SolveTestCase() << '\n';
	return 0;
}