#include "fish.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn=100000+10,maxh=3000+10;
int n,m;
vector<pair<int,int>>allc[maxn];
long long dpn[maxh][maxh],dps[maxh][maxh],nau[maxh][maxh],inf=1e16,all[maxh][maxh];
long long solve(){
long long mainres=0;
for(int i=2;i<=n;i++){
long long unnow=-inf;
for(int j=n;j>=0;j--){
dpn[i][j]=max(dpn[i][j],unnow);
dpn[i][j]=max(dpn[i-1][j],dpn[i][j]);
dpn[i][j]=max(dpn[i][j],dps[i-1][j]);
if(i==n){
mainres=max(mainres,dpn[i][j]);
}
unnow=max(max(unnow,dpn[i-1][j]),dps[i-1][j])+all[i][j];
}
unnow=0;
for(int j=0;j<=n;j++){
unnow=max(unnow+all[i-1][j],dps[i-1][j]);
dps[i][j]=max(dps[i][j],unnow);
if(i==n){
mainres=max(mainres,dps[i][j]);
}
}
unnow=0;
for(int j=n;j>=0;j--){
unnow=max(unnow,nau[i-1][j]);
dps[i][j]=max(dps[i][j],unnow);
dpn[i][j]=max(dpn[i][j],unnow);
}
unnow=0;
for(int j=0;j<=n;j++){
unnow=max(unnow+all[i-1][j],nau[i-1][j]);
dps[i][j]=max(dps[i][j],unnow);
dpn[i][j]=max(dpn[i][j],unnow);
}
unnow=0;
for(int j=0;j<=n;j++){
unnow+=all[i][j];
nau[i][j]=max(dpn[i-1][j],dps[i-1][j])+unnow;
if(i==n){
mainres=max(mainres,nau[i][j]);
}
}
for(int j=0;j<n;j++){
if(all[i][j+1]==0){
dpn[i][j]=dps[i][j]=-inf;
}
}
}
return mainres;
}
long long 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++){
Y[i]++;
X[i]++;
all[X[i]][Y[i]]+=W[i];
allc[X[i]].push_back(make_pair(Y[i],W[i]));
}
for(int i=0;i<=n;i++){
sort(allc[i].begin(),allc[i].end());
}
return solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1041 ms |
137668 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
3160 KB |
Output is correct |
2 |
Execution timed out |
1097 ms |
147464 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1065 ms |
120660 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
3164 KB |
Output is correct |
2 |
Correct |
1 ms |
3244 KB |
Output is correct |
3 |
Correct |
1 ms |
2908 KB |
Output is correct |
4 |
Correct |
1 ms |
2908 KB |
Output is correct |
5 |
Correct |
1 ms |
2908 KB |
Output is correct |
6 |
Correct |
1 ms |
2908 KB |
Output is correct |
7 |
Correct |
0 ms |
3164 KB |
Output is correct |
8 |
Correct |
1 ms |
2908 KB |
Output is correct |
9 |
Correct |
2 ms |
13148 KB |
Output is correct |
10 |
Correct |
5 ms |
21648 KB |
Output is correct |
11 |
Correct |
3 ms |
13148 KB |
Output is correct |
12 |
Correct |
4 ms |
21596 KB |
Output is correct |
13 |
Correct |
1 ms |
8028 KB |
Output is correct |
14 |
Correct |
4 ms |
21596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
3164 KB |
Output is correct |
2 |
Correct |
1 ms |
3244 KB |
Output is correct |
3 |
Correct |
1 ms |
2908 KB |
Output is correct |
4 |
Correct |
1 ms |
2908 KB |
Output is correct |
5 |
Correct |
1 ms |
2908 KB |
Output is correct |
6 |
Correct |
1 ms |
2908 KB |
Output is correct |
7 |
Correct |
0 ms |
3164 KB |
Output is correct |
8 |
Correct |
1 ms |
2908 KB |
Output is correct |
9 |
Correct |
2 ms |
13148 KB |
Output is correct |
10 |
Correct |
5 ms |
21648 KB |
Output is correct |
11 |
Correct |
3 ms |
13148 KB |
Output is correct |
12 |
Correct |
4 ms |
21596 KB |
Output is correct |
13 |
Correct |
1 ms |
8028 KB |
Output is correct |
14 |
Correct |
4 ms |
21596 KB |
Output is correct |
15 |
Correct |
4 ms |
21596 KB |
Output is correct |
16 |
Correct |
2 ms |
8028 KB |
Output is correct |
17 |
Correct |
12 ms |
23132 KB |
Output is correct |
18 |
Correct |
11 ms |
23388 KB |
Output is correct |
19 |
Correct |
12 ms |
23216 KB |
Output is correct |
20 |
Correct |
12 ms |
23388 KB |
Output is correct |
21 |
Correct |
11 ms |
23388 KB |
Output is correct |
22 |
Correct |
20 ms |
24924 KB |
Output is correct |
23 |
Correct |
5 ms |
21884 KB |
Output is correct |
24 |
Correct |
9 ms |
22664 KB |
Output is correct |
25 |
Correct |
4 ms |
21596 KB |
Output is correct |
26 |
Correct |
7 ms |
21852 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
3164 KB |
Output is correct |
2 |
Correct |
1 ms |
3244 KB |
Output is correct |
3 |
Correct |
1 ms |
2908 KB |
Output is correct |
4 |
Correct |
1 ms |
2908 KB |
Output is correct |
5 |
Correct |
1 ms |
2908 KB |
Output is correct |
6 |
Correct |
1 ms |
2908 KB |
Output is correct |
7 |
Correct |
0 ms |
3164 KB |
Output is correct |
8 |
Correct |
1 ms |
2908 KB |
Output is correct |
9 |
Correct |
2 ms |
13148 KB |
Output is correct |
10 |
Correct |
5 ms |
21648 KB |
Output is correct |
11 |
Correct |
3 ms |
13148 KB |
Output is correct |
12 |
Correct |
4 ms |
21596 KB |
Output is correct |
13 |
Correct |
1 ms |
8028 KB |
Output is correct |
14 |
Correct |
4 ms |
21596 KB |
Output is correct |
15 |
Correct |
4 ms |
21596 KB |
Output is correct |
16 |
Correct |
2 ms |
8028 KB |
Output is correct |
17 |
Correct |
12 ms |
23132 KB |
Output is correct |
18 |
Correct |
11 ms |
23388 KB |
Output is correct |
19 |
Correct |
12 ms |
23216 KB |
Output is correct |
20 |
Correct |
12 ms |
23388 KB |
Output is correct |
21 |
Correct |
11 ms |
23388 KB |
Output is correct |
22 |
Correct |
20 ms |
24924 KB |
Output is correct |
23 |
Correct |
5 ms |
21884 KB |
Output is correct |
24 |
Correct |
9 ms |
22664 KB |
Output is correct |
25 |
Correct |
4 ms |
21596 KB |
Output is correct |
26 |
Correct |
7 ms |
21852 KB |
Output is correct |
27 |
Correct |
130 ms |
286040 KB |
Output is correct |
28 |
Correct |
50 ms |
61460 KB |
Output is correct |
29 |
Correct |
163 ms |
277328 KB |
Output is correct |
30 |
Correct |
172 ms |
296272 KB |
Output is correct |
31 |
Correct |
169 ms |
296276 KB |
Output is correct |
32 |
Correct |
75 ms |
51028 KB |
Output is correct |
33 |
Correct |
166 ms |
296372 KB |
Output is correct |
34 |
Correct |
166 ms |
296436 KB |
Output is correct |
35 |
Correct |
133 ms |
290180 KB |
Output is correct |
36 |
Correct |
164 ms |
255312 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1065 ms |
120660 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1041 ms |
137668 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |