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
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
#define vi vector<int>
#define vb vector<bool>
#define vvi vector<vi>
#define vpii vector<pair<int, int>>
#define str string
#define vs vector<str>
#define lli long long int
#define vc vector<char>
#define vvc vector<vc>


int main()
{
    std::ios_base::sync_with_stdio (false);

    int n, k;
    cin >> n >> k;

    vvi piramida(n);
    for (int i = 0; i < n; i++)
    {
        piramida[i].resize(i+1);
        for (int j = 0; j <= i; j++) {
            cin >> piramida[i][j];
        }
    }

    vvi do_zdjecia(n);
    for (int i = 0; i < n; i++)
    {
        do_zdjecia[i].resize(i+1);
    }
    
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <= i; j++) {
            do_zdjecia[i][j] = (j+1)*(i-j+1);
        }
    }

    int oldest = 2020;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <= i; j++) {
            if (piramida[i][j] < oldest && do_zdjecia[i][j] <= k)
                oldest = piramida[i][j];
        }
    }



    cout << oldest << endl;

    return 0;
}