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

using namespace std;

int main() {
	int n;
	int k;

	cin >> n >> k;

	int minimum = 2019;
	int current;

	for (int i = 1; i <= min(n, k); ++i) {
		int nextReasonableColumn = 0; 

		for (int j = 1; j <= i; ++j) {
			cin >> current;

			if (j >= nextReasonableColumn) {
				if(nextReasonableColumn > 0 || (i - j + 1) * j <= k) {
					if (current < minimum) {
						minimum = current;
					}
				}
				else {
					nextReasonableColumn = i - j + 2;
				}
			}
		}
	}

	cout << minimum << endl;

	return 0;
}