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;
#define sp " "
#define endl "\n"
#define pii pair<int, int>
#define st first
#define nd second
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define pb push_back
#define ll long long
#define LL node * 2
#define RR node * 2 + 1
#define MAXN 300005
const int modulo = 1e9 + 7;
const ll INF = 2e18 + 7;
ll dp[2][2][MAXN], arr[MAXN];
long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
int n = N, m = M;
for (int i = 0; i <= n; i++) arr[i] = 0;
for (int i = 0; i < m; i++) arr[X[i] + 1] = W[i];
dp[1][0][n + 1] = arr[n];
for (int i = n; i >= 1; i--){
for (int j = 0; j < 2; j++){
for (int k = 0; k < 2; k++){
dp[j][k][i] = 0;
for (int l = 0; l < 2; l++){
ll curr = dp[k][l][i + 1];
if ((j == 1 || l == 1) && k == 0) curr += arr[i - 1];
dp[j][k][i] = max(dp[j][k][i], curr);
}
}
}
}
return dp[0][0][1];
}
/*
int main() {
fileio();
int N, M;
assert(2 == scanf("%d %d", &N, &M));
std::vector<int> X(M), Y(M), W(M);
for (int i = 0; i < M; ++i) {
assert(3 == scanf("%d %d %d", &X[i], &Y[i], &W[i]));
}
long long result = max_weights(N, M, X, Y, W);
printf("%lld\n", result);
return 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... |