#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
const int maxN = 100005;
const long long INF = 1e18;
// 0: fish exist
// 1: pier
// 2: claimed
long long dp[3][maxN];
long long val[maxN];
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
std::vector<int> W) {
for (auto x : Y) {
assert (x == 0);
}
long long sum = 0;
for(int i = 0; i < M; i++) {
val[X[i] + 1] = W[i];
}
for(int i = 1; i <= N; i++) {
sum += val[i];
}
assert (sum > 0);
dp[0][0] = 0;
dp[1][0] = -INF;
dp[2][0] = -INF;
for(int i = 1; i <= N + 1; i++){
dp[0][i] = max({dp[2][i - 1], dp[0][i - 1]});
dp[1][i] = max({dp[1][i - 1] + val[i + 1] - val[i], dp[0][i - 1] + val[i - 1] + val[i + 1], dp[2][i - 1] + val[i + 1]});
dp[2][i] = dp[1][i - 1];
}
return max(dp[0][N + 1], dp[2][N + 1]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
23 ms |
4176 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2644 KB |
Output is correct |
3 |
Correct |
15 ms |
4412 KB |
Output is correct |
4 |
Correct |
12 ms |
4124 KB |
Output is correct |
5 |
Correct |
27 ms |
5748 KB |
Output is correct |
6 |
Correct |
23 ms |
6420 KB |
Output is correct |
7 |
Correct |
27 ms |
6984 KB |
Output is correct |
8 |
Correct |
28 ms |
7020 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2644 KB |
Output is correct |
3 |
Correct |
15 ms |
4412 KB |
Output is correct |
4 |
Correct |
12 ms |
4124 KB |
Output is correct |
5 |
Correct |
27 ms |
5748 KB |
Output is correct |
6 |
Correct |
23 ms |
6420 KB |
Output is correct |
7 |
Correct |
27 ms |
6984 KB |
Output is correct |
8 |
Correct |
28 ms |
7020 KB |
Output is correct |
9 |
Runtime error |
27 ms |
5796 KB |
Execution killed with signal 6 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
23 ms |
4176 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |