#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W)
{
bool subtask1=true, subtask2=true, subtask3=true;
for(int i=0; i<M; i++)
{
if(X[i]%2!=0)subtask1=false;
if(X[i]>1)subtask2=false;
if(Y[i]!=0)subtask3=false;
}
if(subtask1)
{
ll rez=0;
for(int i=0; i<M; i++)rez+=W[i];
return rez;
}
if(subtask2)
{
ll s1=0, s0=0, m[N][2]={0};
for(int i=0; i<M; i++)
{
if(X[i]==0)s0+=W[i];
else s1+=W[i];
m[Y[i]][X[i]]=W[i];
}
for(int i=1; i<N; i++)
{
m[i][0]=m[i-1][0]+m[i][0];
m[i][1]=m[i-1][1]+m[i][1];
}
if(N==2)return max(m[N-1][0], m[N-1][1]);
ll rez=s1;
for(int i=0; i<N; i++)
{
rez=max(rez, m[i][0]+m[N-1][1]-m[i][1]);
}
return rez;
}
if(subtask3)
{
ll m[N]={0};
for(int i=0; i<M; i++)
{
m[X[i]]=W[i];
}
ll dp[N][2]={0};
dp[0][1]=0; dp[0][0]=0;
dp[1][1]=m[0]; dp[1][0]=m[1];
for(int i=2; i<N; i++)
{
dp[i][1]=max(dp[i-1][0], max(dp[i-2][0]+m[i-1], dp[i-1][1]));
dp[i][0]=max(dp[i-1][1]+m[i], dp[i-1][0]);
}
return max(dp[N-1][0], dp[N-1][1]);
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
2124 KB |
Output is correct |
2 |
Correct |
26 ms |
2636 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
82 ms |
7268 KB |
Output is correct |
6 |
Correct |
83 ms |
7268 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
44 ms |
5452 KB |
Output is correct |
3 |
Correct |
54 ms |
6480 KB |
Output is correct |
4 |
Correct |
22 ms |
2156 KB |
Output is correct |
5 |
Correct |
26 ms |
2636 KB |
Output is correct |
6 |
Correct |
1 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 |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
22 ms |
3576 KB |
Output is correct |
13 |
Correct |
27 ms |
4168 KB |
Output is correct |
14 |
Correct |
25 ms |
4692 KB |
Output is correct |
15 |
Correct |
30 ms |
5232 KB |
Output is correct |
16 |
Correct |
25 ms |
4684 KB |
Output is correct |
17 |
Correct |
28 ms |
5212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
2516 KB |
Output is correct |
3 |
Correct |
15 ms |
3624 KB |
Output is correct |
4 |
Correct |
11 ms |
3412 KB |
Output is correct |
5 |
Correct |
27 ms |
4928 KB |
Output is correct |
6 |
Correct |
22 ms |
4940 KB |
Output is correct |
7 |
Correct |
26 ms |
4936 KB |
Output is correct |
8 |
Correct |
36 ms |
4940 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
2516 KB |
Output is correct |
3 |
Correct |
15 ms |
3624 KB |
Output is correct |
4 |
Correct |
11 ms |
3412 KB |
Output is correct |
5 |
Correct |
27 ms |
4928 KB |
Output is correct |
6 |
Correct |
22 ms |
4940 KB |
Output is correct |
7 |
Correct |
26 ms |
4936 KB |
Output is correct |
8 |
Correct |
36 ms |
4940 KB |
Output is correct |
9 |
Incorrect |
25 ms |
2624 KB |
1st lines differ - on the 1st token, expected: '99999', found: '0' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
2124 KB |
Output is correct |
2 |
Correct |
26 ms |
2636 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
82 ms |
7268 KB |
Output is correct |
6 |
Correct |
83 ms |
7268 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
44 ms |
5452 KB |
Output is correct |
9 |
Correct |
54 ms |
6480 KB |
Output is correct |
10 |
Correct |
22 ms |
2156 KB |
Output is correct |
11 |
Correct |
26 ms |
2636 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
22 ms |
3576 KB |
Output is correct |
19 |
Correct |
27 ms |
4168 KB |
Output is correct |
20 |
Correct |
25 ms |
4692 KB |
Output is correct |
21 |
Correct |
30 ms |
5232 KB |
Output is correct |
22 |
Correct |
25 ms |
4684 KB |
Output is correct |
23 |
Correct |
28 ms |
5212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
2 ms |
2516 KB |
Output is correct |
26 |
Correct |
15 ms |
3624 KB |
Output is correct |
27 |
Correct |
11 ms |
3412 KB |
Output is correct |
28 |
Correct |
27 ms |
4928 KB |
Output is correct |
29 |
Correct |
22 ms |
4940 KB |
Output is correct |
30 |
Correct |
26 ms |
4936 KB |
Output is correct |
31 |
Correct |
36 ms |
4940 KB |
Output is correct |
32 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '0' |
33 |
Halted |
0 ms |
0 KB |
- |