#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
const int kMaxN = 100'000;
long long dp[kMaxN][2][2];
int arr[kMaxN];
int N;
long long solve(int col, bool bef2, bool bef) {
if (col == N) {
return 0;
}
long long &ret = dp[col][bef2][bef];
if (ret != -1) {
return ret;
}
// skip
ret = solve(col+1, bef, false);
// take
long long add = 0;
if (col > 0 && bef) add -= arr[col];
if (col > 0 && !bef2 && !bef) add += arr[col-1];
if (col+1 < N) add += arr[col+1];
ret = max(ret, add + solve(col+1, bef, true));
return ret;
}
long long max_weights(int _N, int M, std::vector<int> X, std::vector<int>,
std::vector<int> W) {
N = _N;
for (int i = 0 ; i < M ; i++) {
arr[X[i]] = W[i];
}
memset(dp, -1, sizeof dp);
long long ret = solve(0, false, false);
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
41 ms |
13768 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '803213453' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
3412 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
12820 KB |
Output is correct |
2 |
Correct |
11 ms |
12756 KB |
Output is correct |
3 |
Correct |
26 ms |
13496 KB |
Output is correct |
4 |
Correct |
23 ms |
14548 KB |
Output is correct |
5 |
Correct |
41 ms |
17072 KB |
Output is correct |
6 |
Correct |
41 ms |
16444 KB |
Output is correct |
7 |
Correct |
38 ms |
17092 KB |
Output is correct |
8 |
Correct |
40 ms |
17068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
3412 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
3412 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
3412 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
12820 KB |
Output is correct |
2 |
Correct |
11 ms |
12756 KB |
Output is correct |
3 |
Correct |
26 ms |
13496 KB |
Output is correct |
4 |
Correct |
23 ms |
14548 KB |
Output is correct |
5 |
Correct |
41 ms |
17072 KB |
Output is correct |
6 |
Correct |
41 ms |
16444 KB |
Output is correct |
7 |
Correct |
38 ms |
17092 KB |
Output is correct |
8 |
Correct |
40 ms |
17068 KB |
Output is correct |
9 |
Incorrect |
43 ms |
16820 KB |
1st lines differ - on the 1st token, expected: '99999', found: '66666' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
41 ms |
13768 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '803213453' |
2 |
Halted |
0 ms |
0 KB |
- |