#include "fish.h"
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int max_weights(int32_t N, int32_t M, vector<int32_t> X, vector<int32_t> Y, vector<int32_t> W) {
int n = N, m = M;
vector<vector<int>> c(9, vector<int>(n+1, 0));
vector<vector<int>> dp(9, vector<int>(n+1, 0));
for (int i = 0; i < m; i++) {
c[Y[i]+1][X[i]] = W[i];
}
for (int j = 1; j < n; j++) {
int v = 0;
dp[0][j] = max(dp[0][j], dp[0][j-1]);
for (int i = 1; i < 9; i++) {
v += c[i][j];
dp[0][j] = max(dp[0][j], dp[i][j-1]+v);
}
for (int i = 1; i < 9; i++) {
for (int a = i; a < 9; a++) {
v = 0;
for (int b = i+1; b <= a; b++) {
v += c[b][j];
}
dp[i][j] = max(dp[i][j], dp[a][j-1]+v);
}
for (int a = 1; a <= i; a++) {
v = 0;
for (int b = a+1; b <= i; b++) {
v += c[b][j-1];
}
dp[i][j] = max(dp[i][j], dp[a][j-1]+v);
}
}
if (j == 1) {
v = 0;
for (int i = 1; i < 9; i++) {
v += c[i][j-1];
dp[i][j] = max(dp[i][j], dp[0][j-1]+v);
}
}
if (j-2 >= 0) {
v = 0;
for (int i = 1; i < 9; i++) {
v += c[i][j-1];
dp[i][j] = max(dp[i][j], dp[0][j-2]+v);
}
for (int i = 1; i < 9; i++) {
v = 0;
for (int h = 1; h <= i; h++) {
v += c[h][j-1];
}
for (int h = 1; h <= i; h++) {
dp[i][j] = max(dp[i][j], dp[h][j-2]+v);
}
for (int h = i+1; h < 9; h++) {
v += c[h][j];
dp[i][j] = max(dp[i][j], dp[h][j-2]+v);
}
}
}
}
int ans = 0;
for (int i = 0; i < 9; i++) {
ans = max(ans, dp[i][n-1]);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
39 ms |
31384 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Runtime error |
48 ms |
35384 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
15340 KB |
Output is correct |
2 |
Correct |
31 ms |
15180 KB |
Output is correct |
3 |
Correct |
44 ms |
15004 KB |
Output is correct |
4 |
Correct |
45 ms |
16712 KB |
Output is correct |
5 |
Correct |
48 ms |
19276 KB |
Output is correct |
6 |
Correct |
49 ms |
18500 KB |
Output is correct |
7 |
Correct |
49 ms |
19024 KB |
Output is correct |
8 |
Correct |
50 ms |
19008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '255796868075' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '255796868075' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '255796868075' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
15340 KB |
Output is correct |
2 |
Correct |
31 ms |
15180 KB |
Output is correct |
3 |
Correct |
44 ms |
15004 KB |
Output is correct |
4 |
Correct |
45 ms |
16712 KB |
Output is correct |
5 |
Correct |
48 ms |
19276 KB |
Output is correct |
6 |
Correct |
49 ms |
18500 KB |
Output is correct |
7 |
Correct |
49 ms |
19024 KB |
Output is correct |
8 |
Correct |
50 ms |
19008 KB |
Output is correct |
9 |
Runtime error |
37 ms |
36824 KB |
Execution killed with signal 11 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
39 ms |
31384 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |