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
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

int n, k, i, j, up1, up2, r, a, minn;

int main() {
scanf("%d %d", &n, &k);
minn = INF;
for (i=1;i<=n;i++) for (j=1;j<=i;j++) {
	up1 = j;
	up2 = i - j + 1;
	if (up2 < up1) swap(up1, up2);
	r = up1 * (up1 + 1) / 2;
	r += (up2 - up1) * up1;
	r += (i - up2) * (i - up2 + 1) / 2;
	//printf("%d ", r);
	//if (j==i) printf("\n");
	scanf("%d", &a);
	if (r <= k) minn = min(minn, a);
}
printf("%d\n", minn);
return 0;
}