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
#include <bits/stdc++.h>
#define booost ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define fi first
#define se second
using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;

const LL MOD=1e9+7;
const LL LLINF=1e18+7;
int tab[3000][3000];
int main()
{
    booost;
    //freopen("3.in","r",stdin);
    tab[1][1]=1;
    for(int i=2;i<=2004;i++)
    {
        for(int j=1;j<=i;j++)
        {
            tab[i][j]=tab[i-1][j-1]+tab[i-1][j]-tab[i-2][j-1]+1;
        }
    }
    int n,k,a;
    //cin>>n>>k;
    scanf("%d %d",&n,&k);
    //cout<<n<<'\n';
    int best=2019;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=i;j++)
        {
            //cin>>a;
            scanf("%d", &a);
            if(tab[i][j]<=k)
            {
                best=min(best,a);
            }
        }
    }
    printf("%d\n", best);
    //cout<<best<<'\n';
    return 0;

}