1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>

int minOfKToReach(int n, int m)
{
  return (n - m + 1) * (m + 1);
}

int main()
{
  std::ios::sync_with_stdio(false);
  int N, K, year;
  std::cin >> N >> K;
  int oldestWine = 2020;
  for(int n = 0 ; n < N ; ++n)
    for(int m = 0 ; m <= n ; ++m)
    {
      std::cin >> year;
      if(minOfKToReach(n,m) <= K)
        oldestWine = std::min(oldestWine, year);
    }
  std::cout << oldestWine << std::endl;
  return 0;
}