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

using namespace std;

int main () {
	int n = 0, k = 0;
	
  cin >> n; cin >> k;
  
  int ii = n;

	short tower[n+1][n+1];
	
	if (k < n) {
		ii = k;
	}

	for (int i = 1; i <= ii; i++) {
		for (int j = 1; j <= i; j++) {
			cin >> tower[i][j];
		}
	}
  
  short kingsWine = 3000;
  
  for (int i = 1; i <= ii; i++) {
		if (( i / 2 + 1 ) * ( i - i / 2 ) <= k) {
			for (int j = 1; j <= i; j++) {
				if (tower[i][j] < kingsWine) {
					kingsWine = tower[i][j];
				}
			}
		} else {
			for (int j = 1; j <= i; j++) {
				if (j * ( i - j + 1 ) <= k && tower[i][j] < kingsWine) {
					kingsWine = tower[i][j];
				}
			}
		}
	}
	
	cout << kingsWine;
	
  return 0;
}