1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <bits/stdc++.h>
using namespace std;

const int MAX = 2020;

int dp[2][MAX];

int n, k, a;

int main() {
  int res = 2222;
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    for (int j = (n+1)/2 - i/2, foo = i; foo; foo--, j++) {
      dp[i%2][j] += i;
      scanf("%d", &a);
      if (dp[i%2][j] <= k) {
        res = min(res, a);
      }
    }
  }
  printf("%d", res);
}