#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
set<int>fishies[3002];
ll FIS2;
ll dp[3010][2][3010],fishiess[3010][3010];
inline ll ones(int col,int len){
return fishiess[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].insert(Y[i]+1),
fishiess[X[i]+1][Y[i]+1]=W[i];
for(int i=1;i<=N;i++)
for(int j=1;j<=N+1;j++)
fishiess[i][j]+=fishiess[i][j-1];
for(int i=1;i<=N;i++)
fishies[i].insert(1),
fishies[i].insert(N+1);
fishies[N+1].insert(0);
for(auto i:fishies[1])
dp[1][1][i-1]=ones(2,i-1);
for(int i=2;i<=N;i++){
for(auto rw:fishies[i]) {
ll K=0;
for(auto rw2: fishies[i-2]) { rw2--;
K=max(K,max(dp[i-2][0][rw2],dp[i-2][1][rw2])+
ones(i+1,rw-1)+max(0ll,ones(i-1,rw-1)-ones(i-1,rw2)));
}
dp[i][1][rw-1]=K;
}
for(auto rw:fishies[i-1]) { rw--;
for(auto rw2:fishies[i]){
if(rw2-1>rw) 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(auto rw:fishies[i-1]){rw--;
for(auto rw2:fishies[i]){
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 |
668 ms |
443732 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2648 KB |
Output is correct |
2 |
Runtime error |
701 ms |
455104 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
692 ms |
431956 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2652 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
604 KB |
Output is correct |
7 |
Correct |
0 ms |
584 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
2908 KB |
Output is correct |
10 |
Correct |
3 ms |
8028 KB |
Output is correct |
11 |
Correct |
1 ms |
2908 KB |
Output is correct |
12 |
Correct |
2 ms |
6236 KB |
Output is correct |
13 |
Correct |
1 ms |
1628 KB |
Output is correct |
14 |
Correct |
3 ms |
6236 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2652 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
604 KB |
Output is correct |
7 |
Correct |
0 ms |
584 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
2908 KB |
Output is correct |
10 |
Correct |
3 ms |
8028 KB |
Output is correct |
11 |
Correct |
1 ms |
2908 KB |
Output is correct |
12 |
Correct |
2 ms |
6236 KB |
Output is correct |
13 |
Correct |
1 ms |
1628 KB |
Output is correct |
14 |
Correct |
3 ms |
6236 KB |
Output is correct |
15 |
Correct |
3 ms |
6236 KB |
Output is correct |
16 |
Correct |
2 ms |
3420 KB |
Output is correct |
17 |
Correct |
180 ms |
13592 KB |
Output is correct |
18 |
Correct |
197 ms |
11596 KB |
Output is correct |
19 |
Correct |
115 ms |
11600 KB |
Output is correct |
20 |
Correct |
102 ms |
11756 KB |
Output is correct |
21 |
Correct |
103 ms |
11600 KB |
Output is correct |
22 |
Correct |
462 ms |
15632 KB |
Output is correct |
23 |
Correct |
8 ms |
8520 KB |
Output is correct |
24 |
Correct |
49 ms |
10324 KB |
Output is correct |
25 |
Correct |
3 ms |
8280 KB |
Output is correct |
26 |
Correct |
7 ms |
8472 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2652 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
604 KB |
Output is correct |
7 |
Correct |
0 ms |
584 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
2908 KB |
Output is correct |
10 |
Correct |
3 ms |
8028 KB |
Output is correct |
11 |
Correct |
1 ms |
2908 KB |
Output is correct |
12 |
Correct |
2 ms |
6236 KB |
Output is correct |
13 |
Correct |
1 ms |
1628 KB |
Output is correct |
14 |
Correct |
3 ms |
6236 KB |
Output is correct |
15 |
Correct |
3 ms |
6236 KB |
Output is correct |
16 |
Correct |
2 ms |
3420 KB |
Output is correct |
17 |
Correct |
180 ms |
13592 KB |
Output is correct |
18 |
Correct |
197 ms |
11596 KB |
Output is correct |
19 |
Correct |
115 ms |
11600 KB |
Output is correct |
20 |
Correct |
102 ms |
11756 KB |
Output is correct |
21 |
Correct |
103 ms |
11600 KB |
Output is correct |
22 |
Correct |
462 ms |
15632 KB |
Output is correct |
23 |
Correct |
8 ms |
8520 KB |
Output is correct |
24 |
Correct |
49 ms |
10324 KB |
Output is correct |
25 |
Correct |
3 ms |
8280 KB |
Output is correct |
26 |
Correct |
7 ms |
8472 KB |
Output is correct |
27 |
Correct |
38 ms |
116248 KB |
Output is correct |
28 |
Execution timed out |
1040 ms |
33356 KB |
Time limit exceeded |
29 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
692 ms |
431956 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
668 ms |
443732 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |