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

using namespace std;

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

int ile(int n, int a, int b) {
    return f(a + 1) - f(b) - f(a - b);
}

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

    int n, k;
    cin >> n >> k;

    int res = 2019;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= i; ++j) {
            int a;
            cin >> a;
            if (ile(n, i, j) <= k) {
                res = min(res, a);
            }
        }
    }
    cout << res << "\n";
}