#include <bits/stdc++.h>
#include "fish.h"
using namespace std;
const long long inf=1e18;
long long aa[3069][3069],dp[3069][3069][2];
pair<pair<long long,long long>,long long> a[300069];
long long max_weights(int n,int m,vector<int> xa,vector<int> ya,vector<int> wg)
{
long long i,j,x,y,w,mx,z=-inf;
for(i=1;i<=m;i++)
{
x=xa[i-1]+1;
y=ya[i-1]+1;
w=wg[i-1];
a[i]={{x,y},w};
aa[x][y]=w;
}
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
dp[i][j][0]=dp[i-1][j][0];
}
mx=-inf;
for(j=n;j;j--)
{
mx=max(mx,dp[i-1][j][1]);
if(i>1)
{
mx=max(mx,dp[i-2][j][0]);
}
dp[i][j][0]=max(dp[i][j][0],mx+aa[i][j]);
}
mx=-inf;
for(j=1;j<=n;j++)
{
dp[i][j][0]=max(dp[i][j][0],mx+aa[i][j]);
mx=max(mx,dp[i][j][0]);
}
if(i==1)
{
for(j=1;j<=n;j++)
{
dp[i][j][1]=-inf;
}
}
else
{
for(j=1;j<=n;j++)
{
dp[i][j][1]=dp[i-1][j][1];
}
mx=-inf;
for(j=1;j<=n;j++)
{
mx=max(mx,dp[i-2][j][0]);
dp[i][j][1]=max(dp[i][j][1],mx+aa[i][j]);
}
mx=-inf;
for(j=n;j;j--)
{
dp[i][j][1]=max(dp[i][j][1],mx+aa[i][j]);
mx=max(mx,dp[i][j][1]);
}
}
}
for(i=1;i<=n;i++)
{
z=max(z,max(dp[n][i][1],dp[n-1][i][0]));
}
return z;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1097 ms |
63188 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
1088 ms |
65856 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1091 ms |
52292 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
1748 KB |
Output is correct |
10 |
Correct |
3 ms |
4284 KB |
Output is correct |
11 |
Correct |
1 ms |
1876 KB |
Output is correct |
12 |
Correct |
3 ms |
4180 KB |
Output is correct |
13 |
Correct |
1 ms |
980 KB |
Output is correct |
14 |
Correct |
3 ms |
4052 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
1748 KB |
Output is correct |
10 |
Correct |
3 ms |
4284 KB |
Output is correct |
11 |
Correct |
1 ms |
1876 KB |
Output is correct |
12 |
Correct |
3 ms |
4180 KB |
Output is correct |
13 |
Correct |
1 ms |
980 KB |
Output is correct |
14 |
Correct |
3 ms |
4052 KB |
Output is correct |
15 |
Correct |
3 ms |
4020 KB |
Output is correct |
16 |
Correct |
2 ms |
980 KB |
Output is correct |
17 |
Correct |
16 ms |
6848 KB |
Output is correct |
18 |
Correct |
14 ms |
6720 KB |
Output is correct |
19 |
Correct |
23 ms |
7228 KB |
Output is correct |
20 |
Correct |
24 ms |
6972 KB |
Output is correct |
21 |
Correct |
15 ms |
7252 KB |
Output is correct |
22 |
Correct |
29 ms |
10444 KB |
Output is correct |
23 |
Correct |
5 ms |
5204 KB |
Output is correct |
24 |
Correct |
11 ms |
6660 KB |
Output is correct |
25 |
Correct |
4 ms |
4176 KB |
Output is correct |
26 |
Correct |
5 ms |
4948 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
1748 KB |
Output is correct |
10 |
Correct |
3 ms |
4284 KB |
Output is correct |
11 |
Correct |
1 ms |
1876 KB |
Output is correct |
12 |
Correct |
3 ms |
4180 KB |
Output is correct |
13 |
Correct |
1 ms |
980 KB |
Output is correct |
14 |
Correct |
3 ms |
4052 KB |
Output is correct |
15 |
Correct |
3 ms |
4020 KB |
Output is correct |
16 |
Correct |
2 ms |
980 KB |
Output is correct |
17 |
Correct |
16 ms |
6848 KB |
Output is correct |
18 |
Correct |
14 ms |
6720 KB |
Output is correct |
19 |
Correct |
23 ms |
7228 KB |
Output is correct |
20 |
Correct |
24 ms |
6972 KB |
Output is correct |
21 |
Correct |
15 ms |
7252 KB |
Output is correct |
22 |
Correct |
29 ms |
10444 KB |
Output is correct |
23 |
Correct |
5 ms |
5204 KB |
Output is correct |
24 |
Correct |
11 ms |
6660 KB |
Output is correct |
25 |
Correct |
4 ms |
4176 KB |
Output is correct |
26 |
Correct |
5 ms |
4948 KB |
Output is correct |
27 |
Correct |
154 ms |
156684 KB |
Output is correct |
28 |
Correct |
70 ms |
29440 KB |
Output is correct |
29 |
Correct |
233 ms |
167236 KB |
Output is correct |
30 |
Correct |
250 ms |
210144 KB |
Output is correct |
31 |
Correct |
246 ms |
210716 KB |
Output is correct |
32 |
Correct |
88 ms |
30808 KB |
Output is correct |
33 |
Correct |
281 ms |
236192 KB |
Output is correct |
34 |
Correct |
243 ms |
236128 KB |
Output is correct |
35 |
Correct |
183 ms |
166804 KB |
Output is correct |
36 |
Correct |
235 ms |
180292 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1091 ms |
52292 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1097 ms |
63188 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |