이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "fish.h"
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int n,h;
vector<vector<vector<ll>>> dp;
vector<vector<ll>> fish;
ll f(int x, int j, int k){
if(x<0) return 0;
if(dp[x][j][k]!=-1) return dp[x][j][k];
ll res=0;
for(int i=0;i<h;i++){
ll act=f(x-1,i,j);
if(i<j) act+=fish[x][j]-fish[x][i];
else act+=(x==n-1) ? 0 : fish[x+1][max(i,k)]-fish[x+1][max(j,k)];
res=max(res,act);
}
return dp[x][j][k]=res;
}
ll max_weights(int N, int m, vector<int> x, vector<int> y, vector<int> w){
n=N;
h=0;
for(int i=0;i<m;i++) h=max(h,y[i]);
h+=2;
fish.assign(n,vector<ll>(h,0));
for(int i=0;i<m;i++) fish[x[i]][y[i]+1]=w[i];
for(int i=0;i<n;i++)
for(int j=1;j<h;j++)
fish[i][j]+=fish[i][j-1];
dp.assign(n,vector<vector<ll>>(h,vector<ll>(h,-1)));
return f(n-1,0,0);
}
# | 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... |