#include<bits/stdc++.h>
using namespace std;
constexpr int M=2e3+7;
int strength[M][M];
int howmuch[M][M];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n,k,res=M<<1;
cin>>n>>k;
howmuch[1][1]=1;
for(int i=1; i<=n; i++) for(int j=1; j<=i; j++) cin>>strength[i][j];
for(int i=2; i<=n; i++) for(int j=1; j<=i; j++) howmuch[i][j]=howmuch[i-1][j-1]+howmuch[i-1][j]-howmuch[i-2][j-1]+1;
for(int i=1; i<=n; i++) for(int j=1; j<=i; j++) if(howmuch[i][j]<=k) res=min(res,strength[i][j]);
cout<<res;
return 0;
}
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<bits/stdc++.h> using namespace std; constexpr int M=2e3+7; int strength[M][M]; int howmuch[M][M]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,k,res=M<<1; cin>>n>>k; howmuch[1][1]=1; for(int i=1; i<=n; i++) for(int j=1; j<=i; j++) cin>>strength[i][j]; for(int i=2; i<=n; i++) for(int j=1; j<=i; j++) howmuch[i][j]=howmuch[i-1][j-1]+howmuch[i-1][j]-howmuch[i-2][j-1]+1; for(int i=1; i<=n; i++) for(int j=1; j<=i; j++) if(howmuch[i][j]<=k) res=min(res,strength[i][j]); cout<<res; return 0; } |
English