Submission #950848

#TimeUsernameProblemLanguageResultExecution timeMemory
950848Dec0DeddCatfish Farm (IOI22_fish)C++17
0 / 100
1047 ms57588 KiB
#include <bits/stdc++.h> #include "fish.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; const int N = 310; ll n, m, x[N], y[N], w[N], dp[N][N][N], cnt[N][N], p[N][N]; ll max_weights(int _n, int _m, vector<int> _x, vector<int> _y, vector<int> _w) { n=_n, m=_m; for (int i=1; i<=m; ++i) { x[i]=_x[i-1], y[i]=_y[i-1], w[i]=_w[i-1]; ++x[i], ++y[i]; cnt[x[i]][y[i]]+=w[i]; } for (int i=1; i<=n; ++i) { for (int j=1; j<=n; ++j) p[i][j]=p[i][j-1]+cnt[i][j]; } for (int i=2; i<=n; ++i) { for (int j=0; j<=n; ++j) { for (int k=0; k<=n; ++k) { if (k == 0) { int mx=n; if (i == 2) mx=0; for (int l=0; l<=mx; ++l) { dp[i][k][j]=max(dp[i][k][j], dp[i-1][l][0]+p[i-1][max(l, j)]); } } // to optimize for (int x=0; x<=k; ++x) { dp[i][k][j]=max(dp[i][k][j], dp[i-1][x][k]+p[i-1][j]-p[i-1][k]); } if (k >= j && i > 2) { for (int x=k; x<=n; ++x) { dp[i][k][j]=max(dp[i][k][j], dp[i-1][x][k]+p[i-1][x]-p[i-1][k]); } } } } } //cout<<"eee "<<dp[2][1][0]<<"\n"; ll ans=0; for (int i=0; i<=n; ++i) { for (int j=0; j<=n; ++j) { if (j < i) ans=max(ans, dp[n][i][j]+p[n][i]-p[n][j]); ans=max(ans, dp[n][i][j]); } } 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...