#include "fish.h"
#include "bits/stdc++.h"
#define int long long
using namespace std;
int dp[311][311][311];
int vct[311][311];
int vctt[311][311];
set<int>v[311];
int N;
int slv(int a,int b,int c){
if(a==N)return 0;
if(dp[a][b][c]!=-1)return dp[a][b][c];
// cerr<<a<<' '<<b<<endl;
int mx=0;
int tot=0;
for(auto &i:v[a]){
if(i<=b)tot-=vct[a][i];
if(i>max(b,c))tot+=vct[a-1][i];
tot+=vct[a+1][i];
mx=max(mx,slv(a+1,i,b)+tot);
}
return dp[a][b][c]=mx;
}
long long max_weights(int32_t n, int32_t m, std::vector<int32_t> x, std::vector<int32_t> y, std::vector<int32_t> w) {
N=n;
if(n>300){
int g=0;
for(auto &i:w)g+=i;
return g;
}
memset(dp,-1,sizeof dp);
for(int i=0;i<=n;i++)v[i].insert(0);
for(int i=0;i<m;i++){
vct[x[i]][y[i]+1]=w[i];
if(x[i])v[x[i]-1].insert(y[i]+1);
v[x[i]].insert(y[i]+1);
v[x[i]+1].insert(y[i]+1);
}
return slv(0,0,0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
2172 KB |
Output is correct |
2 |
Correct |
29 ms |
3456 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
80 ms |
8188 KB |
Output is correct |
6 |
Correct |
68 ms |
8224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
71 ms |
235652 KB |
Output is correct |
2 |
Incorrect |
51 ms |
4856 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 |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
11 ms |
1480 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 |
72 ms |
235848 KB |
Output is correct |
2 |
Correct |
68 ms |
235784 KB |
Output is correct |
3 |
Correct |
75 ms |
235740 KB |
Output is correct |
4 |
Correct |
78 ms |
235736 KB |
Output is correct |
5 |
Correct |
83 ms |
235756 KB |
Output is correct |
6 |
Correct |
91 ms |
235708 KB |
Output is correct |
7 |
Correct |
71 ms |
235664 KB |
Output is correct |
8 |
Correct |
69 ms |
235740 KB |
Output is correct |
9 |
Correct |
71 ms |
236172 KB |
Output is correct |
10 |
Correct |
88 ms |
236660 KB |
Output is correct |
11 |
Correct |
89 ms |
236216 KB |
Output is correct |
12 |
Correct |
84 ms |
236656 KB |
Output is correct |
13 |
Correct |
123 ms |
235908 KB |
Output is correct |
14 |
Correct |
110 ms |
236624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
235848 KB |
Output is correct |
2 |
Correct |
68 ms |
235784 KB |
Output is correct |
3 |
Correct |
75 ms |
235740 KB |
Output is correct |
4 |
Correct |
78 ms |
235736 KB |
Output is correct |
5 |
Correct |
83 ms |
235756 KB |
Output is correct |
6 |
Correct |
91 ms |
235708 KB |
Output is correct |
7 |
Correct |
71 ms |
235664 KB |
Output is correct |
8 |
Correct |
69 ms |
235740 KB |
Output is correct |
9 |
Correct |
71 ms |
236172 KB |
Output is correct |
10 |
Correct |
88 ms |
236660 KB |
Output is correct |
11 |
Correct |
89 ms |
236216 KB |
Output is correct |
12 |
Correct |
84 ms |
236656 KB |
Output is correct |
13 |
Correct |
123 ms |
235908 KB |
Output is correct |
14 |
Correct |
110 ms |
236624 KB |
Output is correct |
15 |
Correct |
86 ms |
236512 KB |
Output is correct |
16 |
Correct |
183 ms |
236096 KB |
Output is correct |
17 |
Execution timed out |
1090 ms |
241028 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
235848 KB |
Output is correct |
2 |
Correct |
68 ms |
235784 KB |
Output is correct |
3 |
Correct |
75 ms |
235740 KB |
Output is correct |
4 |
Correct |
78 ms |
235736 KB |
Output is correct |
5 |
Correct |
83 ms |
235756 KB |
Output is correct |
6 |
Correct |
91 ms |
235708 KB |
Output is correct |
7 |
Correct |
71 ms |
235664 KB |
Output is correct |
8 |
Correct |
69 ms |
235740 KB |
Output is correct |
9 |
Correct |
71 ms |
236172 KB |
Output is correct |
10 |
Correct |
88 ms |
236660 KB |
Output is correct |
11 |
Correct |
89 ms |
236216 KB |
Output is correct |
12 |
Correct |
84 ms |
236656 KB |
Output is correct |
13 |
Correct |
123 ms |
235908 KB |
Output is correct |
14 |
Correct |
110 ms |
236624 KB |
Output is correct |
15 |
Correct |
86 ms |
236512 KB |
Output is correct |
16 |
Correct |
183 ms |
236096 KB |
Output is correct |
17 |
Execution timed out |
1090 ms |
241028 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
11 ms |
1480 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 |
17 ms |
2172 KB |
Output is correct |
2 |
Correct |
29 ms |
3456 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
80 ms |
8188 KB |
Output is correct |
6 |
Correct |
68 ms |
8224 KB |
Output is correct |
7 |
Correct |
71 ms |
235652 KB |
Output is correct |
8 |
Incorrect |
51 ms |
4856 KB |
1st lines differ - on the 1st token, expected: '40604614618209', found: '80901044391025' |
9 |
Halted |
0 ms |
0 KB |
- |