1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
    int n, k, cur, arr[2002][2002];
    cin>>n>>k;
    int best = 2020;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= i; ++j) {
            cin>>cur;
            if (j == 1 || j == i) arr[i][j] = i;
            else arr[i][j] = arr[i - 1][j - 1] + arr[i - 1][j] - arr[i - 2][j - 1] + 1;
            if (arr[i][j] <= k) best = min(best, cur);
        }
    }
    cout<<best<<endl;
    return 0;
}