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
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
// TEMPLATE
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <exception>
#include <forward_list>
#include <fstream>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define FE(i, a, b) for (size_t i = a; i < b; i++)
#define FI(i, a, b) for (size_t i = a; i <= b; i++)
#define RFE(i, a, b) for (int i = a; i > b; i--)
#define RFI(i, a, b) for (int i = a; i >= b; i--)
#define FEA(i, c) for (auto&& i : c)
#define FEAC(i, c) for (typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define RANGE(c) (c).begin(), (c).end()
#define mp std::make_pair
#define fi first
#define se second
#define th third
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define bgn begin
#define ers erase
#define ins insert
#define putcxi putchar_unlocked
#define getcxi getchar_unlocked
#define y1 __y1
#define esle else
#define szie size
#define boid void

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pi;
typedef std::pair<int, ll> pill;
typedef std::pair<ll, int> plli;
typedef std::pair<ll, ll> pll;
typedef std::vector<int> vi;
typedef std::vector<pill> vpill;
typedef std::vector<plli> vplli;
typedef std::vector<ll> vll;
typedef std::vector<pi> vpi;
typedef std::vector<vi> vvi;
typedef std::vector<vll> vvll;
typedef std::vector<vvi> vvvi;
typedef std::vector<vpi> vvpi;
typedef std::vector<bool> vb;
typedef std::vector<vb> vvb;
typedef std::set<int> si;
typedef std::set<long long> sll;

const int MAX_INT = std::numeric_limits<int>::max();
const int MXI = 1e9;
const ll MAX_LL = std::numeric_limits<long long>::max();
const ull MAX_ULL = std::numeric_limits<unsigned long long>::max();
const ll MXLL = 1e18;

template <typename T1, typename T2, typename T3>
class triple {
public:
    T1 first;
    T2 second;
    T3 third;

    triple() {}
    triple(T1 first, T2 second, T3 third)
        : first(first)
        , second(second)
        , third(third)
    {
    }
    triple(const triple& t) = default;
    triple(triple&& t) = default;

    triple& operator=(const triple& t)
    {
        first = t.first;
        second = t.second;
        third = t.third;
        return *this;
    }
    bool operator==(const triple& t) const
    {
        return first == t.first && second == t.second && third == t.third;
    }
    bool operator!=(const triple& t) const
    {
        return !(*this == t);
    }
    bool operator<(const triple& t) const
    {
        if (first == t.first) {
            if (second == t.second)
                return third < t.third;
            return second < t.second;
        }
        return first < t.first;
    }
    bool operator>(const triple& t) const
    {
        if (first == t.first) {
            if (second == t.second)
                return third > t.third;
            return second > t.second;
        }
        return first > t.first;
    }
    bool operator<=(const triple& t) const
    {
        return !(*this > t);
    }
    bool operator>=(const triple& t) const
    {
        return !(*this < t);
    }

    friend std::ostream& operator<<(std::ostream& os, const triple& t)
    {
        return os << t.fi << ' ' << t.se << ' ' << t.th << ' ';
    }
};

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
    return os << p.fi << ' ' << p.se << ' ';
}
template <typename... T, template <typename...> class Container, typename std::enable_if<!std::is_same<Container<T...>, std::string>::value>::type* = nullptr>
std::ostream& operator<<(std::ostream& os, const Container<T...>& c)
{
    for (auto&& x : c)
        std::cout << x << ' ';
    // std::cout << '\n';
    return os;
}
template <typename T, typename std::enable_if<std::is_integral<T>::value>::type* = nullptr>
inline void getcx(T& var)
{
    var = 0;
    register char c = getchar();
    register T sgn = 1;
    while (c < '0' || c > '9') {
        if (c == '-')
            sgn *= -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        var = (var << 3) + (var << 1) + c - '0';
        c = getchar();
    }
    var *= sgn;
}
template <typename T, typename std::enable_if<std::is_integral<T>::value>::type* = nullptr>
inline void putcx(T var)
{
    if (var == 0) {
        putchar('0');
        putchar(' ');
        return;
    }
    register T rev = 0;
    register int zeros = 0;
    while (var % 10 == 0) {
        zeros++;
        var /= 10;
    }
    while (var) {
        rev = (rev << 3) + (rev << 1) + (var % 10);
        var /= 10;
    }
    while (rev) {
        putchar(rev % 10 + '0');
        rev /= 10;
    }
    while (zeros--)
        putchar('0');
    putchar(' ');
}
// KOD CODE PROGRAM SOURCE
int n, k;
int min = MXI;

void Update(int row, int col, int val)
{
    if (row == 1) {
        min = val;
        return;
    }
    int needed = 0;
    if (col > (row >> 1))
        col = row - col + 1;
    needed += (col * (col + 1)) >> 1;
    int tempRow = row - col;
    if (tempRow > col)
        needed += (tempRow - col) * col;
    needed += (col * (col + 1)) >> 1;
    if (k >= needed)
        min = val;
}

int main()
{
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);

    std::cin >> n >> k;
    FI (i, 1, n) {
        FI (j, 1, i) {
            int a;
            std::cin >> a;
            if (a < min)
                Update(i, j, a);
        }
    }

    std::cout << min << '\n';
    return 0;
}