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;
const int nax = 100000;
long long fish[nax];
long long dp[nax][2];
int n;
long long solve(int i, int mask) {
if(i==n) return 0LL;
long long &ret = dp[i][mask];
if(ret!=-1) return ret;
ret = solve(i+1, 1);
if(mask) ret = max(ret, solve(i+1, 0) + fish[i]);
else if(i < n-1) ret = max(ret, solve(i+2, 1) + fish[i]);
return ret;
}
long long max_weights(int N, int M, vector<int> X, vector<int> Y,
vector<int> W) {
n = N;
for(int i=0; i<M; ++i) {
fish[X[i]] = W[i];
}
memset(dp, -1, sizeof dp);
return solve(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... |