Submission #1075640

#TimeUsernameProblemLanguageResultExecution timeMemory
1075640Sir_Ahmed_ImranCatfish Farm (IOI22_fish)C++17
35 / 100
73 ms12452 KiB
///~~~LOTA~~~/// #include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define append push_back #define add insert #define nl '\n' #define ff first #define ss second #define pii pair<int,int> #define pll pair<ll,ll> #define all(x) (x).begin(),(x).end() #define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define terminator main #define N 301 ll hs[N][N]; ll dp[N][N]; ll dp2[N][N]; ll max_weights(int n,int m,vector<int> x,vector<int> y,vector<int> w){ for(int i=0;i<m;i++) hs[x[i]+1][y[i]+1]+=w[i]; for(int i=1;i<=n;i++) for(int j=0;j<n;j++) hs[i][j+1]+=hs[i][j]; for(int i=1;i<=n;i++) dp[0][i]=dp2[0][i]=-1e17; for(int i=1;i<=n;i++){ for(int j=0;j<=n;j++){ for(int k=0;k<=n;k++){ if(j<k){ dp[i][j]=max(dp[i][j],dp[i-1][k]+hs[i][k]-hs[i][j]); dp2[i][k]=max(dp2[i][k],dp[i-1][k]+hs[i][k]-hs[i][j]); } else{ dp[i][j]=max(dp[i][j],dp2[i-1][k]+hs[i-1][j]-hs[i-1][k]); dp2[i][j]=max(dp2[i][j],dp2[i-1][k]+hs[i-1][j]-hs[i-1][k]); } } dp2[i][j]=max(dp2[i][j],dp[i-1][j]+hs[i][j]); } } ll ans=0; for(int i=0;i<=n;i++) ans=max(ans,max(dp[n][i],dp2[n][i])); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...