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

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int oldest = 2020;
  for (int i = 1; i <= n; i++) {
    int bottles = 0;
    for (int j = 1; j <= i; j++) {
      int year;
      scanf("%d", &year);
      bottles += i - j + 1; // i, i-1, i-2, ...
      bottles -= j - 1; // 0, 1, 2, ...
      if (bottles <= k && year < oldest) {
        oldest = year;
      }
    }
  }
  printf("%d\n", oldest);
  return 0;
}