#include "fish.h"
#include <bits/stdc++.h>
//#include "grader.cpp"
using namespace std;
#define ll long long
#define sc second
#define fr first
#define pb push_back
long long max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w){
bool sb1=1,sb2=1,sb3=1;
for(int i=0;i<m;i++){
sb1&=(x[i]%2==0);
sb2&=(x[i]<=1);
sb3&=(y[i]==0);
}
if(sb1){
ll sum=0;
for(int i=0;i<m;i++) sum+=w[i];
return sum;
}
if(sb2){
vector<ll> a(n),b(n);
ll A=0,B=0;
for(int i=0;i<m;i++){
if(x[i]==0){
A+=w[i];
a[y[i]]=w[i];
}
else{
B+=w[i];
b[y[i]]=w[i];
}
}
if(n==2) return max(A,B);
ll x=0,y=B;
for(int i=0;i<n;i++){
x+=a[i];
y-=b[i];
B=max(B,x+y);
}
return B;
}
if(sb3){
vector<ll> a(n);
for(int i=0;i<m;i++)
a[x[i]]=w[i];
vector<ll> dp(n),mx(n);
for(int i=1;i<n;i++){
dp[i]=mx[i-1]+a[i];
mx[i]=max(mx[i-1],dp[i-1]);
if(i>1) mx[i]=max(max(mx[i-2],dp[i-2])+a[i-1],mx[i]);
else mx[i]=max(a[i-1],mx[i]);
}
ll ans=0;
for(int i=0;i<n;i++) ans=max({ans,dp[i],mx[i]});
return ans;
}
}
Compilation message
fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:59:1: warning: control reaches end of non-void function [-Wreturn-type]
59 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
2156 KB |
Output is correct |
2 |
Correct |
25 ms |
2640 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
66 ms |
7268 KB |
Output is correct |
6 |
Correct |
69 ms |
7264 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
38 ms |
5400 KB |
Output is correct |
3 |
Correct |
51 ms |
6496 KB |
Output is correct |
4 |
Correct |
17 ms |
2156 KB |
Output is correct |
5 |
Correct |
23 ms |
2632 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
7 ms |
212 KB |
Output is correct |
9 |
Correct |
1 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 |
18 ms |
3540 KB |
Output is correct |
13 |
Correct |
22 ms |
4168 KB |
Output is correct |
14 |
Correct |
19 ms |
3540 KB |
Output is correct |
15 |
Correct |
20 ms |
3940 KB |
Output is correct |
16 |
Correct |
19 ms |
3540 KB |
Output is correct |
17 |
Correct |
21 ms |
3928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
13 ms |
3632 KB |
Output is correct |
4 |
Correct |
10 ms |
4060 KB |
Output is correct |
5 |
Correct |
24 ms |
6568 KB |
Output is correct |
6 |
Correct |
19 ms |
5952 KB |
Output is correct |
7 |
Correct |
23 ms |
6456 KB |
Output is correct |
8 |
Correct |
27 ms |
6476 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
13 ms |
3632 KB |
Output is correct |
4 |
Correct |
10 ms |
4060 KB |
Output is correct |
5 |
Correct |
24 ms |
6568 KB |
Output is correct |
6 |
Correct |
19 ms |
5952 KB |
Output is correct |
7 |
Correct |
23 ms |
6456 KB |
Output is correct |
8 |
Correct |
27 ms |
6476 KB |
Output is correct |
9 |
Incorrect |
21 ms |
6348 KB |
1st lines differ - on the 1st token, expected: '99999', found: '66666' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
2156 KB |
Output is correct |
2 |
Correct |
25 ms |
2640 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
66 ms |
7268 KB |
Output is correct |
6 |
Correct |
69 ms |
7264 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
38 ms |
5400 KB |
Output is correct |
9 |
Correct |
51 ms |
6496 KB |
Output is correct |
10 |
Correct |
17 ms |
2156 KB |
Output is correct |
11 |
Correct |
23 ms |
2632 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
7 ms |
212 KB |
Output is correct |
15 |
Correct |
1 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 |
18 ms |
3540 KB |
Output is correct |
19 |
Correct |
22 ms |
4168 KB |
Output is correct |
20 |
Correct |
19 ms |
3540 KB |
Output is correct |
21 |
Correct |
20 ms |
3940 KB |
Output is correct |
22 |
Correct |
19 ms |
3540 KB |
Output is correct |
23 |
Correct |
21 ms |
3928 KB |
Output is correct |
24 |
Correct |
0 ms |
212 KB |
Output is correct |
25 |
Correct |
2 ms |
2644 KB |
Output is correct |
26 |
Correct |
13 ms |
3632 KB |
Output is correct |
27 |
Correct |
10 ms |
4060 KB |
Output is correct |
28 |
Correct |
24 ms |
6568 KB |
Output is correct |
29 |
Correct |
19 ms |
5952 KB |
Output is correct |
30 |
Correct |
23 ms |
6456 KB |
Output is correct |
31 |
Correct |
27 ms |
6476 KB |
Output is correct |
32 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
33 |
Halted |
0 ms |
0 KB |
- |