#include <bits/stdc++.h>
#include "fish.h"
using namespace std;
#define ll long long int
#define MAXN 300064
ll pond[MAXN], dp[MAXN][2];
ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W){
for (int i = 0; i < M; ++i) pond[X[i] + 1] = W[i];
for(int i = 2; i < N + 1; i++){
dp[i][0] = max(dp[i - 1][0], dp[i - 1][1] + pond[i]); dp[i][1] = dp[i - 1][1];
if (i > 2) dp[i][1] = max({dp[i][1], dp[i - 2][0] + pond[i - 1], dp[i - 2][1] + pond[i - 1]});
else dp[i][1] = max(dp[i][1], pond[i - 1]);
}
ll ans = 0;
for (int i = 1; i < N + 1; i++) ans = max({ans, dp[i][0], dp[i][1]});
return (*max_element(Y.begin(), Y.end()) ? accumulate(W.begin(), W.end(), 0ll) : ans);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
3540 KB |
Output is correct |
2 |
Correct |
27 ms |
4176 KB |
Output is correct |
3 |
Correct |
2 ms |
1876 KB |
Output is correct |
4 |
Correct |
2 ms |
1876 KB |
Output is correct |
5 |
Correct |
86 ms |
8908 KB |
Output is correct |
6 |
Correct |
86 ms |
9588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
46 ms |
5544 KB |
1st lines differ - on the 1st token, expected: '40604614618209', found: '80901044391025' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1876 KB |
Output is correct |
2 |
Correct |
1 ms |
1876 KB |
Output is correct |
3 |
Correct |
16 ms |
3668 KB |
Output is correct |
4 |
Correct |
12 ms |
3176 KB |
Output is correct |
5 |
Correct |
27 ms |
4948 KB |
Output is correct |
6 |
Correct |
22 ms |
4948 KB |
Output is correct |
7 |
Correct |
34 ms |
4932 KB |
Output is correct |
8 |
Correct |
26 ms |
4952 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '4044', found: '6066' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '4044', found: '6066' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '4044', found: '6066' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1876 KB |
Output is correct |
2 |
Correct |
1 ms |
1876 KB |
Output is correct |
3 |
Correct |
16 ms |
3668 KB |
Output is correct |
4 |
Correct |
12 ms |
3176 KB |
Output is correct |
5 |
Correct |
27 ms |
4948 KB |
Output is correct |
6 |
Correct |
22 ms |
4948 KB |
Output is correct |
7 |
Correct |
34 ms |
4932 KB |
Output is correct |
8 |
Correct |
26 ms |
4952 KB |
Output is correct |
9 |
Correct |
26 ms |
4952 KB |
Output is correct |
10 |
Incorrect |
31 ms |
4548 KB |
1st lines differ - on the 1st token, expected: '36454348383152', found: '49943314382825' |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
3540 KB |
Output is correct |
2 |
Correct |
27 ms |
4176 KB |
Output is correct |
3 |
Correct |
2 ms |
1876 KB |
Output is correct |
4 |
Correct |
2 ms |
1876 KB |
Output is correct |
5 |
Correct |
86 ms |
8908 KB |
Output is correct |
6 |
Correct |
86 ms |
9588 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Incorrect |
46 ms |
5544 KB |
1st lines differ - on the 1st token, expected: '40604614618209', found: '80901044391025' |
9 |
Halted |
0 ms |
0 KB |
- |