1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int n, k, curr, best = 2020;
int a[2002][2002];
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= i; j++) {
      cin >> curr;
      if (j == 1 || j == i) {
        a[i][j] = i;
      } else {
        a[i][j] = 1 + a[i-1][j] + a[i-1][j-1] - a[i-2][j-1];
      }
      if (a[i][j] <= k && curr < best) {
        best = curr;
      }
    }
  }
  cout << best << endl;
}