Submission #849372

#TimeUsernameProblemLanguageResultExecution timeMemory
849372sonamoo메기 농장 (IOI22_fish)C++17
0 / 100
1081 ms261088 KiB
#include <fish.h> #include <bits/stdc++.h> #define MAX 200005 #define INF 1e12 #define ll long long #define pii pair<int,int> #define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); using namespace std; vector<pair<ll,ll> > fish; long long dp[333][333][333]; long long a[333][333] , ps[333][333]; long long ma1[333] , ma2[333]; long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) { ll ans = 0; for (int i = 0; i < M; i++) a[X[i]+1][Y[i]+1] += W[i]; for (int i = 1; i <= N; i++) for (int j = 1; j <= N; j++) ps[j][i] = ps[j-1][i]+a[j][i]; for (int i = 2; i <= N+1; i++) { for (int h1 = 0; h1 <= N; h1++) { ll ma = 0; for (int i = 0; i <= N; i++) ma1[i] = ma2[i] = 0; for (int k = 0; k <= N; k++) ma = max(ma , dp[i-1][k][h1]); for (int h2 = 0; h2 <= N; h2++) ma1[h2] = max(((h2 == 0) ? 0 : ma1[h2-1]) , dp[i-1][h2][h1]+ps[h2][i-1]-ps[h1][i-1]); for (int h2 = N-1; h2 >= 0; h2--) ma2[h2] = max(ma2[h2+1] , dp[i-1][h2+1][h1]+ps[h2+1][i-1]-ps[h1][i-1]); for (int h2 = 0; h2 <= N; h2++) dp[i][h1][h2] = max(ma , max(ma1[h2] , ma2[h2])); } } for (int i = 0; i <= N; i++) { for (int j = 0; j <= N; j++) ans = max(ans , dp[N+1][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...