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 <vector>
#include <algorithm>
using namespace std;
struct fish
{
int x, y, w;
bool operator<(const fish &f)
{
return x < f.x;
}
};
vector<fish> v;
long long dp[300005][2];
long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W)
{
v.push_back({-1, -1, -1});
for(int i = 0; i < M; i++)
v.push_back({X[i], Y[i], W[i]});
sort(v.begin(), v.end());
dp[0][0] = 0;
dp[0][1] = 0;
for(int i = 1; i <= M; i++)
{
dp[i][0] = v[i].w + dp[i - 1][1];
dp[i][1] = max(dp[i - 1][0], dp[i - 1][1]);
}
return max(dp[M][0], dp[M][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... |