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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <cstdio>
#include <cassert>
#include <algorithm>

using namespace std;

const int max_size = 2002;

int tab[max_size][max_size];
int n, k;


inline int calc_num_of_bottles(int i, int j)
{
        j = min(j, i+1-j);
        return j*(i+1-j);
}

int main()
{
        int max_dept, cur_min;

        scanf("%d\n", &n);
        scanf("%d\n", &k);
        
        max_dept = min(n, k);

        for(int i = 1; i <= n; ++i) {
                for(int j = 1; j <= i; ++j) {
                        scanf("%d\n", &(tab[i][j]));
                }
        }

        cur_min = 2020;
        for(int i = 1; i <= max_dept; ++i) {
                for(int j = 1; j <= i; ++j) {
                        //printf("(%d,%d) -> %d\n", i, j, calc_num_of_bottles(i, j));
                        if (k >= calc_num_of_bottles(i, j)) {
                                if (tab[i][j] < cur_min) {
                                        cur_min = tab[i][j];
                                }
                        }
                }
        }

        printf("%d\n", cur_min);
        return 0;
}