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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <algorithm>
#include <iostream>
#include <vector>
#include <bitset>

using namespace std;
#define int2 pair<int, int>
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define forEach(a) for(int i = 0; i < a.size(); i++)
#define vec vector

const int size = 1e5 + 9;

int N, K;
vec<vec<int>> tab;

void init() {
    cin >> N >> K;

    tab.resize(N);

    for (int i = 0; i < N; i++)
        for (int j = 0; j <= i; j++) {
            int t;
            cin >> t;

            tab[i].pb(t);
        }
}

void solve() {

    int out = 2019;

    int taken = 0;
    int fromTop = 0;
    int cost = 1;
    for (int i = 0; i < N; i++) {
        fromTop = i;
        taken = 0;

        while (taken <= K && fromTop <= N) {
            if (taken != 0)
                out = min(out, tab[fromTop - 1][i]);

            taken += cost;
            fromTop++;
        }

        cost++;
    }

    cout << out << "\n";
}

int main(int argc, const char * argv[]) {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    init();
    solve();

    return 0;
}

/*
5 7
1999
2019 2010
850 1500 1600
900 900 710 900
1000 800 600 800 1000
*/