Submission #1177801

#TimeUsernameProblemLanguageResultExecution timeMemory
1177801PagodePaivaCatfish Farm (IOI22_fish)C++20
14 / 100
32 ms7496 KiB
#include "fish.h" #include<bits/stdc++.h> #define ll long long using namespace std; const int N = 310; const int MAXY = 10; ll dp[N][MAXY][MAXY][MAXY]; ll mat[N][N]; ll calc(int i, int y1, int y2, int y3){ ll sum = 0; for(int j = y2+1;j <= max(y1, y3);j++){ sum += mat[i][j]; } return sum; } long long max_weights(int n, int m, std::vector<int> X, std::vector<int> Y, std::vector<int> W) { for(int i = 0;i < m;i++){ mat[X[i]+1][Y[i]+1] = W[i]; } for(int i = 0;i < N;i++) for(int y1 = 0;y1 < MAXY;y1++) for(int y2 = 0;y2 < MAXY;y2++) for(int y3 = 0;y3 < MAXY;y3++) dp[i][y1][y2][y3] = -1e18; for(int i = 0;i < MAXY;i++){ for(int j = 0;j < MAXY;j++){ dp[0][0][0][j] = 0; } } for(int i = 1;i <= n;i++){ for(int y1 = 0;y1 < MAXY;y1++){ for(int y2 = 0;y2 < MAXY;y2++){ for(int y3 = 0;y3 < MAXY;y3++){ for(int k = 0;k < MAXY;k++){ dp[i][y1][y2][y3] = max(dp[i][y1][y2][y3], dp[i-1][k][y1][y2]+calc(i, y1, y2, y3)); } } } } } ll ans = 0; for(int y1 = 0;y1 < MAXY;y1++){ for(int y2 = 0;y2 < MAXY;y2++){ ans = max(ans, dp[n][y1][y2][0]); } } 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...