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
48
49
50
51
52
53
54
55
56
#include <iostream>
#include <vector>
#include <algorithm>

struct Node {
	int x, y, year, path;
};

int path(int x, int y) {
	return x * (y - x + 1);
}

int main() {
	std::ios_base::sync_with_stdio(0);
	std::cin.tie(0);
	int n, k;
	std::cin >> n >> k;
	int numOfNodes = n * (n + 1) / 2;
	std::vector<Node> nodes(numOfNodes);

	int index = 0;
	int bestYet = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < i + 1; j++)
		{
			std::cin >> nodes[index].year;
			nodes[index].x = j + 1;
			nodes[index].y = i + 1;
			nodes[index].path = path(j + 1, i + 1);
			//std::cout << nodes[index].path << " ";
			if (nodes[bestYet].year > nodes[index].year && nodes[index].path <= k) {
				bestYet = index;
			}
			++index;
		}
	}
	std::cout << nodes[bestYet].year;
	//struct
	//{
	//	inline bool operator() (const Node& struct1, const Node& struct2)
	//	{
	//		return (struct1.year < struct2.year);
	//	}
	//} custom;
	////std::cout << path(3, 5);
	//std::sort(nodes.begin(), nodes.end(), custom);
	//for (int i = 0; i < numOfNodes; i++)
	//{
	//	if (nodes[i].path <= k) {
	//		std::cout << nodes[i].year;
	//		break;
	//	}
	//}

}