#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mxn = 1e5 + 5;
ll n, m, w[mxn], dp[mxn][2][2][2], res = 0;
ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
n = N, m = M;
for (int i = 0; i < m; i++) w[X[i] + 1] = W[i];
if (n < 3) return max(w[1], w[2]);
dp[3][0][0][0] = 0;
dp[3][0][0][1] = w[2];
dp[3][0][1][0] = w[1];
dp[3][0][1][1] = w[1];
dp[3][1][0][0] = w[2];
dp[3][1][0][1] = w[2];
dp[3][1][1][0] = 0;
dp[3][1][1][1] = 0;
for (int i = 4; i <= n; i++) {
for (int h = 0; h <= 1; h++) for (int h1 = 0; h1 <= 1; h1++) for (int h2 = 0; h2 <= 1; h2++) {
for (int h3 = 0; h3 <= 1; h3++) {
dp[i][h2][h1][h] = max(dp[i][h2][h1][h], dp[i - 1][h3][h2][h1] + ((h2 || h) && !h1 ? w[i - 1] : 0));
}
}
}
for (int h = 0; h <= 1; h++) for (int h1 = 0; h1 <= 1; h1++) for (int h2 = 0; h2 <= 1; h2++) {
res = max(res, dp[n][h2][h1][h] + (h1 && !h ? w[n] : 0));
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
9148 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 |
1 ms |
304 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 |
5 ms |
6448 KB |
Output is correct |
2 |
Correct |
5 ms |
6484 KB |
Output is correct |
3 |
Correct |
20 ms |
8788 KB |
Output is correct |
4 |
Correct |
15 ms |
8488 KB |
Output is correct |
5 |
Correct |
31 ms |
11212 KB |
Output is correct |
6 |
Correct |
26 ms |
10568 KB |
Output is correct |
7 |
Correct |
30 ms |
11200 KB |
Output is correct |
8 |
Correct |
31 ms |
11212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
304 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 |
1 ms |
304 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 |
1 ms |
304 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 |
5 ms |
6448 KB |
Output is correct |
2 |
Correct |
5 ms |
6484 KB |
Output is correct |
3 |
Correct |
20 ms |
8788 KB |
Output is correct |
4 |
Correct |
15 ms |
8488 KB |
Output is correct |
5 |
Correct |
31 ms |
11212 KB |
Output is correct |
6 |
Correct |
26 ms |
10568 KB |
Output is correct |
7 |
Correct |
30 ms |
11200 KB |
Output is correct |
8 |
Correct |
31 ms |
11212 KB |
Output is correct |
9 |
Incorrect |
30 ms |
11156 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 |
27 ms |
9148 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '803213453' |
2 |
Halted |
0 ms |
0 KB |
- |