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>
using namespace std;
#define int long long int
int max_weights(int32_t N, int32_t M, vector<int32_t> X, vector<int32_t> Y, vector<int32_t> W) {
int n = N, m = M;
vector<vector<int>> c(1, vector<int>(n+1, 0));
vector<vector<vector<int>>> dp(1, vector<vector<int>>(n+1, vector<int>(2, 0)));
for (int i = 0; i < m; i++) {
c[Y[i]][X[i]] = W[i];
}
int i = 0;
for (int j = 0; j < n; j++) {
if (j-1 >= 0) {
dp[i][j][0] = max(dp[i][j][0], dp[i][j-1][1]+c[i][j]);
dp[i][j][0] = max(dp[i][j][0], dp[i][j-1][0]);
dp[i][j][1] = max(dp[i][j][1], dp[i][j-1][0]);
dp[i][j][1] = max(dp[i][j][1], dp[i][j-1][1]);
}
if (j == 1) {
dp[i][j][1] = max(dp[i][j][1], dp[i][j-1][0]+c[i][j-1]);
}
if (j-2 >= 0) {
dp[i][j][1] = max(dp[i][j][1], dp[i][j-2][0]+c[i][j-2]);
dp[i][j][1] = max(dp[i][j][1], dp[i][j-2][1]+c[i][j-2]);
}
}
return max(dp[0][n-1][0], dp[0][n-1][1]);
}
# | 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... |