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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* ==============================================================================
 *
 *  Author:
 *      Name:       Adam Jeliński
 *      Nickname:   charodziej <https://github.com/charodziej>
 *
 *  Created:        18:47 10.12.2019
 *
 *  d1b.cpp
 *
 *  g++ -std=c++11 -O3 -o d1b.o d1b.cpp
 *  ./d1b.o
 *
 * ============================================================================== */

#include <bits/stdc++.h>
using namespace std;

#ifndef DEBUG
#define DEBUG 0
#elif DEBUG==1
#include "/home/charodziej/Documents/universal-print-in-cpp/lib/universal_print.h"
#endif
#if DEBUG==0
#define watch(...)
#define debug if(0)
namespace cupl{
    template <typename T> void print_main(T &x, int y, std::string z){return;}
    std::string indentation = "";
    void indent(){return;}
    void unindent(){return;}
    std::string bold(){return "";}
    std::string clr(){return "";}
    std::string backgr(int x){return "";}
    std::string colour(int x){return "";}
    void showTypes(bool val){return;}
    template <typename T> bool is_iterable(T x){return 0;}
    void print_process(...){return;}
}
void print_process(...){return;}
#endif

/* ============================================================================== *
 *     /\                   Please pardon the code above                   /\     *
 *     ||       It is necessary for my library to function properly        ||     *
 * ============================================================================== */

typedef   signed long long  ll;
typedef unsigned long long ull;

constexpr int SIZE = 2010;
int tab[SIZE][SIZE];

int main(){
#if DEBUG==0
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#endif

    int n, k;
    while(cin >> n >> k){
    
    int a;
    int mini = 1e9;
    for (int i = 2; i < n + 2; ++i) {
        for (int j = 2; j <= i; ++j) {
            cin >> a;
            tab[i][j] = tab[i - 1][j - 1] + tab[i - 1][j] - tab[i - 2][j - 1] + 1;
            if (tab[i][j] <= k) {
                mini = min(mini, a);
            }
        }
    }
    cout << mini << '\n';
    }
}