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 "fish.h"
#include<bits/stdc++.h>
#include <vector>
using namespace std;
long long haha[5000][5000];
long long dp[300][300][300];
long long max_weights(int n, int m, std::vector<int> x, std::vector<int> y, std::vector<int> w) {
for(long long i = 0; i < n; i++) {
for(long long j = 0; j < n; j++) {
haha[i][j] = 0;
}
}
for(long long i = 0; i < m; i++) {
haha[x[i]][y[i]+1] = w[i];
}
for(long long i = 0; i < n; i++) {
for(long long j = 1; j <= n; j++) {
haha[i][j]+=haha[i][j-1];
}
}
for(long long i = 0; i <= n; i++) {
for(long long j = 0; j <= n; j++) {
dp[0][i][j] = 0;
}
}
long long ans = 0;
for(long long i = 1; i < n; i++) {
for(long long j = 0; j <= n; j++) {
if(i == 1 && j > 0) {
continue;
}
for(long long k = 0; k <= n; k++) {
for(long long y = 0; y <= n; y++) {
long long c = dp[i-1][j][k];
if(max(j,y) > k) {
c+=haha[i-1][max(j,y)]-haha[i-1][k];
}
dp[i][k][y] = max(c,dp[i][k][y]);
}
}
}
}
for(long long i = 0; i <= n; i++) {
for(long long j = 0; j <= n; j++) {
long long c = dp[n-1][i][j];
if(i > j) {
c+=haha[n-1][i]-haha[n-1][j];
}
ans = max(ans,c);
}
}
return ans;
}
# | 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... |