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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,k;
	cin >> n >> k;
	set < pair < int,int> > but;
	for(int i = 1; i <= k; i++){
		for(int j = 1; j <= k/i; j++){
			but.insert(make_pair(j-1+i-1,j-1));
		}
	}
	int c;
	pair < int,int > p;
	int wyn = 2019;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < i+1; j++){
			cin >> c;
			p = make_pair(i,j);
			if(but.find(p) != but.end()){
				wyn = min(wyn,c);
			}
		}
	}
	cout << wyn;
}