#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
const long long inf = -(1LL << 60);
long long max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w) {
vector p(n, vector<int>(n + 1));
for (int i = 0; i < m; i++) {
p[x[i]][y[i] + 1] = w[i];
}
vector s(n, vector<long long>(n + 2));
for (int i = 0; i < n; i++) {
for (int j = 0; j <= n; j++) {
s[i][j + 1] = s[i][j] + p[i][j];
}
}
vector dp(n + 1, array<long long, 2>{inf, inf});
dp[0] = {0, 0};
for (int i = 0; i < n; i++) {
auto pd = dp;
dp = vector(n + 1, array<long long, 2>{inf, inf});
for (int j = 0; j <= n; j++) {
dp[0][0] = max(dp[0][0], max(pd[j][0], pd[j][1]));
dp[0][1] = max(dp[0][1], max(pd[j][0], pd[j][1]));
}
for (int j = 1; j <= n; j++) {
for (int k = 0; k <= j; k++) {
dp[j][0] = max(dp[j][0], pd[k][0] + (i == 0 ? 0 : s[i - 1][j + 1] - s[i - 1][k + 1]));
}
for (int k = j; k <= n; k++) {
dp[j][1] = max(dp[j][1], max(pd[k][0], pd[k][1]) + s[i][k + 1] - s[i][j + 1]);
}
}
}
long long ans = inf;
for (int i = 0; i <= n; i++) {
ans = max(ans, max(dp[i][0], dp[i][1]));
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1192 ms |
1902684 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Runtime error |
973 ms |
2097152 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
871 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
216 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Incorrect |
0 ms |
312 KB |
1st lines differ - on the 1st token, expected: '8866', found: '7755' |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
216 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Incorrect |
0 ms |
312 KB |
1st lines differ - on the 1st token, expected: '8866', found: '7755' |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
216 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Incorrect |
0 ms |
312 KB |
1st lines differ - on the 1st token, expected: '8866', found: '7755' |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
871 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1192 ms |
1902684 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |