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
#include <vector>
#include <cstdio>
#include <iostream>
using namespace std;

int bottles(int y, int x) {
    return (x + 1) * (y - x);
}

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    
    vector<vector<int>> pyramid(n + 1);
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < i; j++) {
            int year;
            scanf("%d", &year);
            pyramid[i].push_back(year);
        }
    }
    
    int out = 2020;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < i; j++) {
            //cerr << i << " " << j << " " <<bottles(i, j) << "\n";
            if (pyramid[i][j] < out && bottles(i, j) <= k)
                out = pyramid[i][j];
        }
    }
    
    printf("%d", out);
    return 0;
}