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;
// Subtask 3
bool cmp(array<int, 3> a, array<int, 3> b)
{
if(a[1] != b[1]) return a[1] < b[1];
return a[0] > b[0];
}
long long max_weights(int N, int M, std::vector<int> X,
std::vector<int> Y, std::vector<int> W) {
vector<long long> vect(N, 0);
for(int i = 0; i < M; i++)
{
vect[X[i]] += W[i];
}
if(N == 2)
{
return max(vect[0], vect[1]);
}
vector<long long> dp(N, 0);
dp[0] = vect[0];
dp[1] = max(dp[0], vect[1]);
dp[2] = max(dp[1], dp[0] + vect[2]);
long long ans = dp[2];
for(int i = 3; i < N; i++)
{
dp[i] = max(dp[i - 1], dp[i - 2] + vect[i]);
ans = max(ans, dp[i]);
}
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... |