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 <bits/stdc++.h>
#include "fish.h"
using namespace std;
#define pb push_back
#define ll long long
#define fi first
#define se second
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
std::vector<int> W) {
int n=N;int m=M;
long long dp[n][2][2];
memset(dp,0,sizeof dp);
vector<int> tab(n,0);
for (int i = 0; i < m; ++i)
{
tab[X[i]]+=W[i];
}
dp[0][0][1]=tab[0];
for (int i = 1; i < n; ++i)
{
dp[i][0][0]=dp[i-1][1][0]+tab[i];
if(i<n-1) dp[i][0][1]=dp[i-1][0][0]+tab[i];
dp[i][1][0]=max({dp[i-1][1][0],dp[i-1][0][0],dp[i-1][0][1]});
}
return max(dp[n-1][1][0],dp[n-1][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... |