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

long int availability[2020];
int main()
{
  for (unsigned int i=1; i<2020; ++i)
  {
    availability[i] = 4000000;	
  }
  unsigned int n, year;
  long int k, available;
  std::cin >> n;
  std::cin >> k;
  for (unsigned int i=1; i<=n; ++i)
  {
  	for (unsigned int j=1; j<=i; ++j)
  	{
  	  std::cin >> year;
  	  available = (i-j+1)*j;
  	  if (available < availability[year])
  	    availability[year] = available;
    }
  }
  for (unsigned int i=1; i<2020; ++i)
  {
  	if (availability[i] <= k)
    {
      std::cout << i;
	  break;	
    }  	
  }	
  return 0;
}