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;
typedef long long ll;
typedef vector<int> vi;
#define FOR(i,a,b) for(int i = a; i < b; i++)
ll max_weights(int N, int M, vi X, vi Y, vi W) {
vector<ll> A(N);
FOR(i,0,M){
A[X[i]] = W[i];
}
ll dp[N][2]; memset(dp,0,sizeof(dp));
if (N>1){
dp[1][0] = A[1];
dp[1][1] = A[0];
}
FOR(i,2,N){
dp[i][0] = dp[i-1][1] + A[i];
dp[i][1] = max(max(dp[i-1][1], dp[i-1][0]), dp[i-2][0] + A[i-1]);
}
FOR(i,0,M){
if (Y[i] > 0){
ll ans = 0; FOR(j,0,M) ans += W[j];
return ans;
}
}
return max(dp[N-1][0], dp[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... |