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
36
37
38
39
40
41
42
43
44
45
#include <bits/stdc++.h>

using namespace std;

int n, k;

long long triangle(int x){
  return x*(x+1)/2;
}

int min_points;

void obt(){
  min_points = 3000;
  int layer = 1;
  int layer_length = 1;
  int counter = 0;
  for(int a = 0; a < (n*(n+1)/2); a++){
    counter++;
    int val;
    cin >> val;
    int cost;
    //cout << "layer: " << layer << " counter: " << counter << endl;
    cost = triangle(layer) - triangle(layer - counter) - triangle(layer - (layer_length-counter+1));
    //cout << triangle(layer) << " " << triangle(layer - counter) << " " << triangle(layer - (layer_length-counter+1)) << endl;
    //cout << "moves: " << t[a].second << endl;
    if(cost <= k){
      if(val < min_points)
        min_points = val;
    }
    if(counter == layer_length){
      layer_length++;
      counter = 0;
      layer++;
    }
  }
  cout << min_points << endl;
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n >> k;
  obt();
}