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

int s(int n) {
    return n*(n+1)/2;
}

int up_including(int n, int k) {
    if (n == 1) return 1;
    k = min(k, n-k+1);
    int res = s(k) + s(k) + (n-k-k)*k;
    return res;
}

int main() {
    int n, k;
    while (scanf("%d", &n) != EOF) {
        scanf("%d", &k);
        int res = 2050;
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j <= i; ++j) {
                int val;
                scanf("%d", &val);
                if (up_including(i+1, j+1) <= k) {
                    res = min(res, val);
                }
            }
        }
        printf("%d\n", res);
    }
    return 0;
}