이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
long long sumtop[3003][3003], sumbot[3003][3003];
long long dp[3003][3003];
long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
for (long long i = 0; i < M; i++) {
sumtop[X[i]+1][Y[i]+1] += W[i];
sumbot[X[i]+1][Y[i]+1] += W[i];
}
for (long long i = 1; i <= N; i++) {
for (long long j = 1; j <= N; j++) sumtop[i][j] += sumtop[i][j-1];
for (long long j = N; j >= 1; j--) sumbot[i][j] += sumbot[i][j-1];
}
for (long long i = 1; i <= N; i++) {
for (long long j = 0; j <= N; j++) {
for (long long k = 0; k <= N; k++) {
dp[i][j] = max(
dp[i][j],
dp[i-1][k] - sumbot[i][min(j, k)] + sumbot[i+1][k] + (k > j ? sumbot[i-1][k] - sumbot[i-1][j] : 0)
);
}
}
}
long long mx = 0;
for (long long j = 0; j <= N; j++) {
mx = max(mx, dp[N][j]);
}
return mx;
}
# | 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... |