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

int main()
{
    int height, maxToGrab;
    std::cin >> height;
    std::cin >> maxToGrab;
    int oldest = 2019;
    for (int h = 1; h <= height; h++) {
        for (int w = 1; w <= h; w++) {
            int currYear;
            std::cin >> currYear;
            int grabs = (h - w + 1) * w;
            if (grabs <= maxToGrab && currYear < oldest) {
                oldest = currYear;
            }
        }
    }
    std::cout << oldest << std::endl;
    return 0;
}