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
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//typedef tree < int , null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> TREE;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define pss pair<short,short>
#define pld pair<long double,long double >
#define ld long double
#define piii  pair<pii,int>
#define vii vector<pair<int,int> >
#define st first
#define nd second
#define speed ios::sync_with_stdio(false);cin.tie();cout.tie();
//#define int long long
//const int mod=1000000007;
//const int mod=1000003;
const int mod=998244353;
const int inf=1000000009;
const long long INF=1000000000000000009;
const long long big=1000000000000000;
const long double eps=0.0000000001;
using namespace std;
int DP[2005][2005];
int main()
{
    int n,k;
    scanf("%d %d",&n,&k);
    int mini=1000000;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=i;j++)
        {
            int a;
            scanf("%d",&a);
            DP[i][j]=DP[i-1][j-1]+DP[i-1][j]+1;
            if(i>1)
                DP[i][j]-=DP[i-2][j-1];
            if(DP[i][j]<=k)
                mini=min(mini,a);
        }
    }
    printf("%d",mini);
    return 0;
}