#include <bits/stdc++.h> #define pb push_back #define pf push_front #define turbo cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); #define fi first #define sc second #define ll long long #define mp make_pair #define un unsigned #define debug 0 using namespace std; const int ile=2007; int pir[ile][ile]; inline int cost(int i,int j){ return (j+1)*(i-j+1); } int main() { turbo int n,k; cin>>n>>k; for(int i=0;i<n;i++) for(int j=0;j<=i;j++) cin>>pir[i][j]; int mini=pir[0][0]; for(int i=0;i<n;i++){ if(cost(i,0)>k) break; for(int j=0;j<=i;j++) if(cost(i,j)<=k) mini=min(mini,pir[i][j]); } cout<<mini; 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #include <bits/stdc++.h> #define pb push_back #define pf push_front #define turbo cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); #define fi first #define sc second #define ll long long #define mp make_pair #define un unsigned #define debug 0 using namespace std; const int ile=2007; int pir[ile][ile]; inline int cost(int i,int j){ return (j+1)*(i-j+1); } int main() { turbo int n,k; cin>>n>>k; for(int i=0;i<n;i++) for(int j=0;j<=i;j++) cin>>pir[i][j]; int mini=pir[0][0]; for(int i=0;i<n;i++){ if(cost(i,0)>k) break; for(int j=0;j<=i;j++) if(cost(i,j)<=k) mini=min(mini,pir[i][j]); } cout<<mini; return 0; } |