#include <bits/stdc++.h>
#include "fish.h"
using namespace std;
long long dp[100005],ar[100005];
long long rec(int i,int m){
if(i==m)return 0;
if(~dp[i])return dp[i];
return dp[i]=max(rec(i+1,m)+ar[i+1],rec(i+2,m)+ar[i]);
}
long long max_weights(int x,int k,vector<int> a,vector<int> b,vector<int> c){
vector<pair<int,int>>l[2];
long long ans=0,cur=0,cur2=0;
bool f=1;
for(int i=0;i<k;i++){
l[a[i]%2].push_back({b[i],c[i]});
if(a[i]%2)cur+=c[i];
else cur2+=c[i];
f&=(b[i]==0);
}
if(f){
for(int i=0;i<x;i++)dp[i]=-1,ar[i]=0;
for(int i=0;i<k;i++)ar[a[i]]+=c[i];
return rec(0,x);
}
sort(l[0].begin(),l[0].end());
sort(l[1].begin(),l[1].end());
ans=cur;
if(x<=2){
return max(cur,cur2);
}
int j=0;
for(int i=0;i<(int)l[0].size();i++){
cur+=l[0][i].second;
while(j<(int)l[1].size()&&l[1][j].first<=l[0][i].first){
cur-=l[1][j].second;
j++;
}
ans=max(ans,cur);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
3268 KB |
Output is correct |
2 |
Correct |
39 ms |
3764 KB |
Output is correct |
3 |
Correct |
3 ms |
4948 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
115 ms |
11488 KB |
Output is correct |
6 |
Correct |
120 ms |
11480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
60 ms |
5740 KB |
Output is correct |
3 |
Correct |
74 ms |
6732 KB |
Output is correct |
4 |
Correct |
29 ms |
3296 KB |
Output is correct |
5 |
Correct |
35 ms |
3780 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 |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
4948 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
35 ms |
3300 KB |
Output is correct |
13 |
Correct |
38 ms |
3784 KB |
Output is correct |
14 |
Correct |
32 ms |
3084 KB |
Output is correct |
15 |
Correct |
34 ms |
3424 KB |
Output is correct |
16 |
Correct |
32 ms |
3184 KB |
Output is correct |
17 |
Correct |
33 ms |
3424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4948 KB |
Output is correct |
2 |
Incorrect |
3 ms |
4948 KB |
1st lines differ - on the 1st token, expected: '882019', found: '1764038' |
3 |
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 |
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 |
3 ms |
4948 KB |
Output is correct |
2 |
Incorrect |
3 ms |
4948 KB |
1st lines differ - on the 1st token, expected: '882019', found: '1764038' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
3268 KB |
Output is correct |
2 |
Correct |
39 ms |
3764 KB |
Output is correct |
3 |
Correct |
3 ms |
4948 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
115 ms |
11488 KB |
Output is correct |
6 |
Correct |
120 ms |
11480 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
60 ms |
5740 KB |
Output is correct |
9 |
Correct |
74 ms |
6732 KB |
Output is correct |
10 |
Correct |
29 ms |
3296 KB |
Output is correct |
11 |
Correct |
35 ms |
3780 KB |
Output is correct |
12 |
Correct |
0 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 |
3 ms |
4948 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
35 ms |
3300 KB |
Output is correct |
19 |
Correct |
38 ms |
3784 KB |
Output is correct |
20 |
Correct |
32 ms |
3084 KB |
Output is correct |
21 |
Correct |
34 ms |
3424 KB |
Output is correct |
22 |
Correct |
32 ms |
3184 KB |
Output is correct |
23 |
Correct |
33 ms |
3424 KB |
Output is correct |
24 |
Correct |
3 ms |
4948 KB |
Output is correct |
25 |
Incorrect |
3 ms |
4948 KB |
1st lines differ - on the 1st token, expected: '882019', found: '1764038' |
26 |
Halted |
0 ms |
0 KB |
- |