1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Karol Kosinski 2019
#include <cstdio>
#include <algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
//#define DEBUG(x...) printf(x)
#define DEBUG(x...)
using namespace std;

int main()
{
    int n, k, min_year = 3000;
    scanf("%d%d", &n, &k);
    FOR(i,0,n) FOR(j,-1,i)
    {
        int y;
        scanf("%d", &y);
        DEBUG("(%d, %d) =\t%d\n", i, j, (j + 2) * (i - j));
        if ((j + 2) * (i - j) <= k)
            min_year = min(min_year, y);
    }
    printf("%d\n", min_year);
    return 0;
}