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
#include <stdio.h>
#include <stdlib.h>

long t[2000][2000];

int main() {
	long n,k;
	short w=2020;
	
	// Read n and k
	scanf("%ld %ld",&n,&k);
	
	// Read wines
	for (long i = 0; i < n; i++) 
	    for (long j = 0; j <= i; j++) {
	        if (i==0 || j==i) 
	          t[i][j] = i+1;
	        else 
	          t[i][j] = t[i-1][j]+(j+1);
	        short wp;
	        scanf("%hd",&wp);
	        if (t[i][j]<=k && wp < w)
	          w = wp;
	    }
	printf("%hd",w);
    return 0;
}