#include <bits/stdc++.h>
#include "fish.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int N = 310;
ll n, m, x[N], y[N], w[N], dp[N][N][N], cnt[N][N], p[N][N];
ll max_weights(int _n, int _m, vector<int> _x, vector<int> _y, vector<int> _w) {
n=_n, m=_m;
for (int i=1; i<=m; ++i) {
x[i]=_x[i-1], y[i]=_y[i-1], w[i]=_w[i-1];
++x[i], ++y[i];
cnt[x[i]][y[i]]+=w[i];
}
for (int i=1; i<=n; ++i) {
for (int j=1; j<=n; ++j) p[i][j]=p[i][j-1]+cnt[i][j];
}
for (int i=2; i<=n; ++i) {
for (int j=0; j<=n; ++j) {
for (int k=0; k<=n; ++k) {
if (k == 0) {
int mx=n;
if (i == 2) mx=0;
for (int l=0; l<=mx; ++l) {
dp[i][k][j]=max(dp[i][k][j], dp[i-1][l][0]+p[i-1][max(l, j)]);
}
}
// to optimize
for (int x=0; x<=k; ++x) {
dp[i][k][j]=max(dp[i][k][j], dp[i-1][x][k]+p[i-1][j]-p[i-1][k]);
}
}
}
}
ll ans=0;
for (int i=0; i<=n; ++i) {
for (int j=0; j<=n; ++j) {
ans=max(ans, dp[n][i][j]);
}
} return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
26 ms |
9832 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Runtime error |
45 ms |
15140 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1047 ms |
11456 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Incorrect |
1 ms |
2396 KB |
1st lines differ - on the 1st token, expected: '4044', found: '2022' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Incorrect |
1 ms |
2396 KB |
1st lines differ - on the 1st token, expected: '4044', found: '2022' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Incorrect |
1 ms |
2396 KB |
1st lines differ - on the 1st token, expected: '4044', found: '2022' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1047 ms |
11456 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
26 ms |
9832 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |