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

using namespace std;

#define N 2048
#define A 2019

int a[N][N];

int f(int r, int c)
{
    int sl = c*(c+1)/2;
    int sr = sl+c*(r-c);
    return sr-sl+r+1;
}

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

    int n, k, ans = A;

    cin >> n >> k;
    /*for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= i; ++j) cerr << setw(4) << f(i, j);
        cerr << '\n';
    }*/
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= i; ++j) {
            cin >> a[i][j];
            if (f(i, j) <= k) ans = min(ans, a[i][j]);
        }
    }
    cout << ans << '\n';

    return 0;
}