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
#include <iostream>
#include <vector>

int n, k;
std::vector<std::vector<int>> wines;

int solve()
{
	int best = 2020;

	for (int i = 0; i < n; ++i)
	{
		for(int j = 0; j < n - i; ++j)
		{
			const int cost = i + j*(i + 1);
			const auto& row = wines[j + i];
			if (cost < k && row[i] < best)
				best = row[i];
		}
	}

	return best;
}


int main()
{
	std::ios::sync_with_stdio(false);
	std::cin >> n >> k;
	wines.resize(n);

	for (int i = 0; i < n; ++i)
	{
		wines[i].resize(i + 1);

		for (auto& j : wines[i])
			std::cin >> j;
	}

	std::cout << solve() << std::endl;

	return 0;
}