#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)
{
ll a=0;
for(int i=0;i<m;i++){
a+=W[i];
}
return a;
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 |
Correct |
13 ms |
2172 KB |
Output is correct |
2 |
Correct |
16 ms |
2724 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
51 ms |
7280 KB |
Output is correct |
6 |
Correct |
60 ms |
7248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
27 ms |
4160 KB |
1st lines differ - on the 1st token, expected: '40604614618209', found: '80901044391025' |
3 |
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 |
Incorrect |
9 ms |
1624 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '26722970331638' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
1 ms |
344 KB |
1st lines differ - on the 1st token, expected: '4044', found: '6066' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
1 ms |
344 KB |
1st lines differ - on the 1st token, expected: '4044', found: '6066' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
1 ms |
344 KB |
1st lines differ - on the 1st token, expected: '4044', found: '6066' |
4 |
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 |
Incorrect |
9 ms |
1624 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '26722970331638' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
2172 KB |
Output is correct |
2 |
Correct |
16 ms |
2724 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
51 ms |
7280 KB |
Output is correct |
6 |
Correct |
60 ms |
7248 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Incorrect |
27 ms |
4160 KB |
1st lines differ - on the 1st token, expected: '40604614618209', found: '80901044391025' |
9 |
Halted |
0 ms |
0 KB |
- |