#include "fish.h"//sub4
#include <bits/stdc++.h>
using namespace std;
long long max_weights(int n, int m,vector<int> x,vector<int> y,vector<int> w)
{
long long tab[n][10]={0},ans=0,dp[n][10][10];
for(int a=0;a<n;a++)
{
for(int b=0;b<10;b++)
{
tab[a][b]=0;
for(int c=0;c<10;c++)
dp[a][b][c]=0;
}
}
for(int a=0;a<m;a++)
tab[x[a]][y[a]+1]=w[a];
for(int a=0;a<n;a++)
{
for(int b=1;b<10;b++)
tab[a][b]+=tab[a][b-1];
}
for(int a=0;a<10;a++)
{
for(int b=0;b<10;b++)
{
if(a>b)
dp[1][a][b]=tab[1][a]-tab[1][b];
else
dp[1][a][b]=tab[0][b]-tab[0][a];
}
}
for(int c=2;c<n;c++)
{
for(int a=0;a<10;a++)
{
for(int b=0;b<10;b++)
{
for(int d=0;d<10;d++)
{
dp[c][a][b]=max(dp[c][a][b],dp[c-1][d][a]);
if(a>b)
dp[c][a][b]=max(dp[c-1][d][a]+tab[c][a]-tab[c][b],dp[c][a][b]);
else if (b>d)
{
dp[c][a][b]=max(dp[c-1][d][a]+tab[c-1][b]-tab[c-1][max(d,a)],dp[c][a][b]);
}
}
}
}
}
for(int a=0;a<10;a++)
{
for(int b=0;b<10;b++)
ans=max(ans,dp[n-1][a][b]);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
253 ms |
79688 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '25109166324195' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
231 ms |
84424 KB |
1st lines differ - on the 1st token, expected: '40604614618209', found: '27415642949734' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
245 ms |
86376 KB |
Output is correct |
2 |
Correct |
220 ms |
86384 KB |
Output is correct |
3 |
Correct |
248 ms |
80068 KB |
Output is correct |
4 |
Correct |
257 ms |
87888 KB |
Output is correct |
5 |
Correct |
264 ms |
90384 KB |
Output is correct |
6 |
Correct |
263 ms |
89720 KB |
Output is correct |
7 |
Correct |
278 ms |
90308 KB |
Output is correct |
8 |
Correct |
238 ms |
90256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 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 |
300 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
2 ms |
568 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
596 KB |
Output is correct |
13 |
Correct |
1 ms |
304 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 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 |
300 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
2 ms |
568 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
596 KB |
Output is correct |
13 |
Correct |
1 ms |
304 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Runtime error |
2 ms |
852 KB |
Execution killed with signal 11 |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 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 |
300 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
2 ms |
568 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
596 KB |
Output is correct |
13 |
Correct |
1 ms |
304 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Runtime error |
2 ms |
852 KB |
Execution killed with signal 11 |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
245 ms |
86376 KB |
Output is correct |
2 |
Correct |
220 ms |
86384 KB |
Output is correct |
3 |
Correct |
248 ms |
80068 KB |
Output is correct |
4 |
Correct |
257 ms |
87888 KB |
Output is correct |
5 |
Correct |
264 ms |
90384 KB |
Output is correct |
6 |
Correct |
263 ms |
89720 KB |
Output is correct |
7 |
Correct |
278 ms |
90308 KB |
Output is correct |
8 |
Correct |
238 ms |
90256 KB |
Output is correct |
9 |
Runtime error |
137 ms |
181060 KB |
Execution killed with signal 11 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
253 ms |
79688 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '25109166324195' |
2 |
Halted |
0 ms |
0 KB |
- |