#include <bits/stdc++.h>
using namespace std;
#define ll long long
int const N=305;
ll dp[N][N],inc[N][N];
ll sm[N][N];
long long max_weights(int n, int m, vector<int> X, vector<int> Y,
vector<int> W)
{
for(int i=0;i<m;i++)
sm[X[i]+1][Y[i]+1]+=W[i];
for (int i = 1; i <=n; ++i)
for(int j=1;j<=n;++j)
sm[i][j]+=sm[i][j-1];
for(int i=2;i<=n;i++)
for(int k=0;k<=n;k++){
//cal inc
for(int p=0;p<=k;p++)
inc[i][k]=max(inc[i][k],max(inc[i-1][p]+sm[i-1][k]-sm[i-1][p],dp[i-1][p]));
dp[i][k]=inc[i][k];
for(int p=k+1;p<=n;p++)
dp[i][k]=max(dp[i][k],dp[i-1][p]+sm[i][p]-sm[i][k]);
// cout<<dp[i][k]<<' ';
// if(k==n)
// cout<<endl;
}
ll ans=0;
for(int i=0;i<=n;i++)
ans=max(ans,dp[n][i]);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
43 ms |
8788 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Runtime error |
63 ms |
12680 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
38 ms |
4924 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
4 ms |
1372 KB |
Output is correct |
10 |
Correct |
26 ms |
2480 KB |
Output is correct |
11 |
Correct |
4 ms |
1372 KB |
Output is correct |
12 |
Correct |
30 ms |
2424 KB |
Output is correct |
13 |
Correct |
1 ms |
860 KB |
Output is correct |
14 |
Correct |
27 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
4 ms |
1372 KB |
Output is correct |
10 |
Correct |
26 ms |
2480 KB |
Output is correct |
11 |
Correct |
4 ms |
1372 KB |
Output is correct |
12 |
Correct |
30 ms |
2424 KB |
Output is correct |
13 |
Correct |
1 ms |
860 KB |
Output is correct |
14 |
Correct |
27 ms |
2396 KB |
Output is correct |
15 |
Correct |
29 ms |
2392 KB |
Output is correct |
16 |
Correct |
2 ms |
860 KB |
Output is correct |
17 |
Correct |
34 ms |
3504 KB |
Output is correct |
18 |
Correct |
34 ms |
3412 KB |
Output is correct |
19 |
Correct |
31 ms |
3412 KB |
Output is correct |
20 |
Correct |
31 ms |
3404 KB |
Output is correct |
21 |
Correct |
34 ms |
3412 KB |
Output is correct |
22 |
Correct |
39 ms |
4688 KB |
Output is correct |
23 |
Correct |
25 ms |
2652 KB |
Output is correct |
24 |
Correct |
28 ms |
3164 KB |
Output is correct |
25 |
Correct |
24 ms |
2396 KB |
Output is correct |
26 |
Correct |
25 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
4 ms |
1372 KB |
Output is correct |
10 |
Correct |
26 ms |
2480 KB |
Output is correct |
11 |
Correct |
4 ms |
1372 KB |
Output is correct |
12 |
Correct |
30 ms |
2424 KB |
Output is correct |
13 |
Correct |
1 ms |
860 KB |
Output is correct |
14 |
Correct |
27 ms |
2396 KB |
Output is correct |
15 |
Correct |
29 ms |
2392 KB |
Output is correct |
16 |
Correct |
2 ms |
860 KB |
Output is correct |
17 |
Correct |
34 ms |
3504 KB |
Output is correct |
18 |
Correct |
34 ms |
3412 KB |
Output is correct |
19 |
Correct |
31 ms |
3412 KB |
Output is correct |
20 |
Correct |
31 ms |
3404 KB |
Output is correct |
21 |
Correct |
34 ms |
3412 KB |
Output is correct |
22 |
Correct |
39 ms |
4688 KB |
Output is correct |
23 |
Correct |
25 ms |
2652 KB |
Output is correct |
24 |
Correct |
28 ms |
3164 KB |
Output is correct |
25 |
Correct |
24 ms |
2396 KB |
Output is correct |
26 |
Correct |
25 ms |
2644 KB |
Output is correct |
27 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 11 |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
38 ms |
4924 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
43 ms |
8788 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |