#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]);
}
if (k >= j && i > 2) {
for (int x=k; x<=n; ++x) {
dp[i][k][j]=max(dp[i][k][j], dp[i-1][x][k]+p[i-1][x]-p[i-1][k]);
}
}
}
}
}
//cout<<"eee "<<dp[2][1][0]<<"\n";
ll ans=0;
for (int i=0; i<=n; ++i) {
for (int j=0; j<=n; ++j) {
if (j < i) ans=max(ans, dp[n][i][j]+p[n][i]-p[n][j]);
ans=max(ans, dp[n][i][j]);
}
} return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
25 ms |
8528 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Runtime error |
44 ms |
12340 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1047 ms |
11460 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2392 KB |
Output is correct |
9 |
Incorrect |
390 ms |
57588 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '170286167826' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2392 KB |
Output is correct |
9 |
Incorrect |
390 ms |
57588 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '170286167826' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2392 KB |
Output is correct |
9 |
Incorrect |
390 ms |
57588 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '170286167826' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1047 ms |
11460 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
25 ms |
8528 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |