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 <iostream>
#include <vector>
#include <cstdio>

using namespace std;

typedef long long LL;

int tr(int a) {
    return a*(a+1)/2;
}

int main()
{
    int n,k,a;
    int mn=2019;
    scanf("%d%d", &n,&k);
    for (int i=1;i<=n;i++) {
        for (int j=1;j<=i;j++) {
            scanf("%d",&a);
            if (a<mn) {
                int s = tr(i)-tr(j-1)-tr(i-j);
                if (k>=s) {
                    mn = a;
                }
            }
        }
    }
    printf("%d\n",mn);
    return 0;
}