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

int howManySteps(int row, int col)
{
    return row*(row+1)/2 - (col-1)*col/2 - (row-col)*(row - col +1)/2;
}

int main() {

    int n,k,currentValue, minimumValue = 2019;
    cin>>n;
    cin>>k;

    for(int i=1; i<=n ; ++i)
    {
        if (i>k)
        {
            break;
        }

        for(int j=1; j<=i; ++j)
        {
            cin>>currentValue;
            if (howManySteps(i,j)<=k && currentValue<minimumValue)
            {
                minimumValue = currentValue;
            }
        }
    }

    cout<<minimumValue;

    return 0;
}