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
#include <algorithm>
#include <stdio.h>
#include <limits.h>

using namespace std;
int MAX_VAL = 20;

int main(){
    long long int height;
    long long int needed;
    long long int year;
    long long int lowest_year = LLONG_MAX;

    scanf("%lld %lld", &height, &needed);

    for (int idx_col = 0; idx_col < height; ++idx_col) {
        for (int idx_row = 0; idx_row <= idx_col; ++idx_row) {
            scanf("%lld", &year);
            if ((idx_col - idx_row + 1) * (idx_row + 1) <= needed) {
                lowest_year = min(lowest_year, year);
            }
        }
    }

    printf("%lld\n", lowest_year);
    return 0;
}