1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#include<cstdio>
const int N=2010;
int n,k,i,j,a[N][N],f[N][N],ans;
int main(){
  while(~scanf("%d%d",&n,&k)){
    ans=~0U>>1;
    for(i=1;i<=n;i++)for(j=1;j<=i;j++)scanf("%d",&a[i][j]),f[i][j]=1;
    for(i=1;i<=n;i++)for(j=1;j<=i;j++){
      f[i][j]+=f[i-1][j-1]+f[i-1][j];
      if(i>=2)f[i][j]-=f[i-2][j-1];
      if(f[i][j]<=k&&a[i][j]<ans)ans=a[i][j];
    }
    printf("%d\n",ans);
  }
}