1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#include <cstdio>
#include <cstdlib>

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    int best = 9999;
    for (int row = 1; row <= n; row++){
        for (int col = 1; col <= row; col++) {
            int year;
            scanf("%d", &year);
            const int cost = (row - col + 1) * col;
            if (cost <= k && best > year) {
                best = year;
            }
        }
    }
    printf("%d\n", best);
}