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
#include<bits/stdc++.h>
#include <iostream>

using namespace std;

int main() {
    int n, k, res = 2020;
    cin >> n >> k;
    vector<vector<int>> wines(n, vector<int>(n));
    vector<vector<int>> deps(n);
    for (int i = 0; i < n; i++) {
        /*for (int j = 0; j < n - i; j++)
            cerr << "  ";*/
        for (int j = 0; j <= i; j++) {
            deps[i].push_back(0);
            if (j == 0 || i - j == 0) {
                deps[i][j] = i + 1;
            } else {
                deps[i][j] = 1 + deps[i - 1][j - 1] + deps[i - 1][j] - deps[i - 2][j - 1];
            }
            //wines[i][j] = -(1000*i+j);
            cin >> wines[i][j];
            //cerr << deps[i][j] << "  ";
            if (deps[i][j] <= k)
                res = min(res, wines[i][j]);
        }
        //cerr << endl;
    }

    cout << res << endl;
    return 0;
}