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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// TEMPLATE START

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

const int MOD = 1000000007;
const int INF = 2147483647;
const ll LINF = 1e18;
const ld PI = 4*atan((ld)1);

#define rep(i,a,b) for (int i=(a); i<(b); ++i)
#define repd(i,a,b) for (int i=((int)(a)); i>=(b); --i)
#define trav(a,x)  for (auto& a : x)
#define all(u) begin(u), end(u)
#define sz(x) (int)x.size()
#define xsort(v, m) rep(i, 0, v.size()) m[i] = i; sort(all(m), [=](int i, int j) {return v[i] < v[j];}); sort(v);

#define pb push_back
#define X first
#define Y second

#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PREC(n) cout<<fixed<<setprecision(n);

#define db(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl;
#define dbv(v) cerr << __LINE__ << ": " << #v << "\n" << v.size() << "\n" << v << "\n";


template <class T, class S> ostream& operator << (ostream& os, const pair<T, S>& p) {
        os << p.X << " " << p.Y;
    return os;
}

template <class T, class S> istream& operator >> (istream& is,  pair<T, S>& p) {
        is >> p.X >> p.Y;
    return is;
}

template <class T> ostream& operator << (ostream& os, const vector<T>& v) {
    rep(i, 0, v.size())
        os << v[i] << " \n" [i == v.size() - 1];
    return os;
}

template <class T> istream& operator >> (istream& is,  vector<T>& v) {
    rep(i, 0, v.size())
        is >> v[i];
    return is;
}


// TEMPLATE END


// SOLUTION START

int tri(int n) {
    return n * (n + 1) / 2;
}

int main() {
    FAST_IO
    int n, k, r = INF;
    cin >> n >> k;
	vvi v(n + 1);
    rep(i, 1, n + 1) {
        v[i] = vi(i);
        cin >> v[i];
    }
    rep(i, 1, n + 1) {
        rep(j, 0, i) {
            if(k >= 1 + tri(i - 1) - tri(j - 1) - tri(i - j - 2))
                r = min(r, v[i][j]);
        }
    }
    cout << r << "\n";
    return 0;
}

// SOLUTION END