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