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
#include <iostream>
#include <bits/stdc++.h>
#include <vector>

using namespace std;

bool in_range(long long i, long long k, long n){
  long s(0);
  for (long nn=1; nn<=n; nn++)
    if (static_cast<long long>(nn*(nn+1)/2) < i)
      s=nn;
    s++;   
  long long x = s*(s+1)/2-i+1;
  long long y = i-(s-1)*s/2;
  if (x*y <=k)
    return true;
  else
    return false;
}


int main()
{

  long n;
  long long k;
 
  cin >> n >> k;
  long long num = n*(n+1)/2;
  int s;

  int curr, ans = 2020;
  for (long long i = 0; i <num; i++)
  {
    cin >> curr;
    if (in_range(i+1,k,n)){
      ans = min(ans, curr);
    }
  }
  cout << ans << endl;
  return 0;
}