#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll fishies[302][302];
ll dp[302][2][302];
inline ll ones(int col,int len){
return fishies[col][len];
}
ll max_weights(int N,int M,vector<int> X,vector<int> Y,vector<int> W) {
for(int i=0;i<M;i++)
fishies[X[i]+1][Y[i]+1]=W[i];
for(int i=1;i<=N;i++)
for(int j=1;j<=N+1;j++)
fishies[i][j]+=fishies[i][j-1];
for(int i=1;i<=N;i++)
dp[1][1][i-1]=ones(2,i-1);
for(int i=2;i<=N+1;i++){
for(int rw=1;rw<=N+1;rw++) {
ll K=0;
for(int rw2=0;rw2<=N;rw2++)
K=max(K,dp[i-2][0][rw2]+ones(i+1,rw-1)+
max(0ll,ones(i-1,rw-1)-ones(i-1,rw2)));
for(int rw2=0;rw2<=N;rw2++)
K=max(K,dp[i-2][0][rw2]+ones(i+1,rw-1)+
max(0ll,ones(i-1,rw-1)-ones(i-1,rw2)));
dp[i][1][rw-1]=K;
}
for(int rw=0;rw<=N;rw++) {
for(int rw2=1;rw2<=N+1;rw2++){
if(rw2-1>fishies[i][rw2]) break;
ll K=ones(i+1,rw2-1)-ones(i,rw2-1)+dp[i-1][0][rw];
dp[i][0][rw2-1]=max(dp[i][0][rw2-1],K);
}
}
for(int rw=0;rw<=N;rw++){
for(int rw2=1;rw2<=N+1;rw2++){
ll K=ones(i+1,rw2-1)-ones(i,min(rw,rw2-1))+
ones(i-1,rw2-1)-ones(i-1,min(rw2-1,rw))+dp[i-1][1][rw];
dp[i][rw2>rw][rw2-1]=max(dp[i][rw2>rw][rw2-1],K);
}
}
}
ll ans=0;
for(int i=0;i<=N;i++)
ans=max({ans,dp[N][0][i],dp[N][1][i]});
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
18 ms |
5724 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Runtime error |
26 ms |
9536 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
1884 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '4044', found: '2022' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '4044', found: '2022' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '4044', found: '2022' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
1884 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
18 ms |
5724 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |