#include "fish.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
//#define int long long
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) {
// y[i] = 0
vector<int> dp(N);
vector<int> a(N, 0);
for (int i = 0; i < M; i++) a[X[i]] = W[i];
int ans = 0;
dp[0] = a[0]; dp[1] = a[1];
for (int i = 2; i < N; i++) {
dp[i] = dp[i - 1];
dp[i] = max(dp[i], dp[i - 2] + a[i]);
dp[i] = max(dp[i], dp[i - 1] - a[i - 1] + a[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... |