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 <iostream>
#include <string>

using namespace std;

long getStepsToBottle(long n, long m) {
    return (n - m) * m + m;
}

int main()
{
  long n, k;
  cin >> n >> k;
  long finestBottleYear = 2000;
  for(long i=0; i<n; ++i) {
      for(long j=0; j<i+1; ++j) {   
        long year;
        cin >> year;
        long steps = getStepsToBottle(i+1, j+1);
        if(steps <= k && year < finestBottleYear) {
            finestBottleYear = year;
        }
      }
  }
  
  cout << finestBottleYear << endl;
}