# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1062216 | MarwenElarbi | Catfish Farm (IOI22_fish) | C++17 | 1047 ms | 2097152 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "fish.h"
using namespace std;
#define pb push_back
#define ll long long
#define fi first
#define se second
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
std::vector<int> W) {
int n=N;int m=M;
long long dp[n][n][2];
memset(dp,0,sizeof dp);
long long grid[n][n];
memset(grid,0,sizeof grid);
for (int i = 0; i < m; ++i)
{
grid[X[i]][Y[i]]=W[i];
}
long long pre[n][n];
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < n; ++j)
{
pre[i][j]=(j ? pre[i][j-1] : 0)+grid[i][j];
}
}
long long ans=0;
for (int i = 1; i < n; ++i)
{
for (int j = 0; j < n; ++j)
{
for (int k = 0; k < n; ++k)
{
if(k>j){
dp[i][j][1]=max(dp[i][j][1],max(dp[i-1][k][0],dp[i-1][k][1])+pre[i][k]-(j>0 ? pre[i][j-1] : 0ll));
}else if(k<j){
dp[i][j][0]=max(dp[i][j][0],dp[i-1][k][0]+pre[i-1][j]-(k>0 ? pre[i-1][k-1] : 0ll));
}else {
dp[i][j][0]=max(dp[i][j][0],dp[i-1][k][0]);
dp[i][j][1]=max(dp[i][j][1],max(dp[i-1][k][0],dp[i-1][k][1]));
}
dp[i][0][0]=max(dp[i][0][0],(dp[i-1][k][1],dp[i-1][k][0]));
}
ans=max(ans,dp[i][j][0]);
ans=max(ans,dp[i][j][1]);
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |