#include "fish.h"
#include<bits/stdc++.h>
using namespace std;
using lint=long long;
const int lim=3e3+100;
int n,m;
lint dp[lim][lim],up[lim][lim];
lint pref[lim][lim];
lint p(int i,int l,int r){
if(r<l)return 0;
if(l){
//cerr<<pref[i][r]<<" "<<pref[i][l-1]<<" "<<pref[i][r]-pref[i][l-1]<<"\n";
return pref[i][r]-pref[i][l-1];
}
return pref[i][r];
}
lint max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
std::vector<int> W) {
n=N,m=M;
for(int i=0;i<m;i++){
pref[X[i]][Y[i]+1]+=W[i];
}
for(int i=0;i<n;i++){
for(int j=1;j<n;j++){
pref[i][j]+=pref[i][j-1];
}
}
n=N,m=M;
for(int i=0;i<n;i++){
dp[0][i]=p(1,0,i);
}
for(int i=1;i<n;i++){
for(int j=0;j<=n;j++){
for(int k=j;k<=n;k++){
dp[i][j]=max(dp[i][j],dp[i-1][k]-p(i,0,j)+p(i+1,0,j));
up[i][k]=max(up[i][k],dp[i-1][k]-p(i,0,j));
}
for(int k=0;k<=j;k++){
dp[i][j]=max(dp[i][j],up[i-1][k]+p(i-1,k+1,j)+p(i+1,0,j));
up[i][j]=max(up[i][j],up[i-1][k]+p(i-1,k+1,j));
}
}
}
lint ans=0;
for(int i=0;i<=n;i++){
ans=max(ans,dp[n-1][i]);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
558 ms |
461908 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Runtime error |
547 ms |
465696 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
550 ms |
458068 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Incorrect |
1 ms |
2392 KB |
1st lines differ - on the 1st token, expected: '4044', found: '2022' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Incorrect |
1 ms |
2392 KB |
1st lines differ - on the 1st token, expected: '4044', found: '2022' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Incorrect |
1 ms |
2392 KB |
1st lines differ - on the 1st token, expected: '4044', found: '2022' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
550 ms |
458068 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
558 ms |
461908 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |