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 x, min = 2020;
    int n, k, a;
    std::cin >> n >> k;
    for(int row=0; row<n && row<k; row++) {
        for(int pos=0; pos<=row; pos++) {
            std::cin >> a;
            if(a < min) {
                x = (row+1)*(row+2)/2 - pos*(pos+1)/2 - (row-pos)*(row-pos+1)/2;
//                std::cout << a << " @ " << row << " " << pos << " " << x << std::endl;
                if(x <= k) {
                    min = a;
                }
            }
        }
    }
    std::cout << min << std::endl;
    return 0;
}