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>
#include <vector>
using ll = long long;
using namespace std;
long long max_weights_st1(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) {
long long y = 0;
for (int i=0; i<M; i++)
{
long long x = W[i];
y+=x;
}
return y;
}
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) {
vector<long long> fish(N, 0);
//we can consider empty cells to have catfish worth 0
for (int i=0; i<M; i++)
fish[X[i]] = W[i];
if (N==2)
return max(fish[0], fish[1]);
vector<ll> dp(N, 0);
dp[1] = max(fish[0], fish[1]);
dp[2] = max(fish[0]+fish[2], fish[1]);
for (int i=3; i<N; i++)
{
dp[i] = max(fish[i], fish[i-1])+dp[i-2];
}
return dp[N-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... |