#include "fish.h"
#include <bits/stdc++.h>
#define MAX 300001
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
set<pll> a[MAX];
set<ll> b[MAX];
ll n,m,k;
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W){
n=N;
m=M;
for(int i=0;i<m;i++){
a[i].insert(make_pair(n-Y[i]-1,W[i]));
b[i].insert(n-Y[i]-1);
}
ll dp[n+1];
dp[0]=0;
dp[1]=0;
ll h=n,sum=0;
if(b[0].size()!=0){
h=*b[0].begin();
for(auto x:a[0]){
sum+=x.second;
}
dp[1]=sum;
}
for(int i=2;i<=n;i++){
dp[i]=dp[i-1];
if(b[i-1].size()!=0){
ll j;
sum=0;
j=distance(b[i-1].begin(),b[i-1].lower_bound(h-1));
if(j==0){
h=n;
}
else{
h=*b[i-1].begin();
}
auto it=a[i-1].begin();
ll z=0;
while(it!=a[i-1].end() && z<j){
dp[i]+=(*it).second;
++it;
z++;
}
sum=0;
for(auto x:a[i-1]){
sum+=x.second;
}
if(sum+dp[i-2]>dp[i]){
dp[i]=sum+dp[i-2];
h=*b[i-1].begin();
}
}
else{
h=n;
}
}
return dp[n];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
45 ms |
39884 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '29265952452551' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 ms |
28396 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
29140 KB |
Output is correct |
2 |
Correct |
18 ms |
29132 KB |
Output is correct |
3 |
Incorrect |
36 ms |
36276 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '15662963514162' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
28372 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 |
14 ms |
28372 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 |
14 ms |
28372 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 |
19 ms |
29140 KB |
Output is correct |
2 |
Correct |
18 ms |
29132 KB |
Output is correct |
3 |
Incorrect |
36 ms |
36276 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '15662963514162' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
45 ms |
39884 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '29265952452551' |
2 |
Halted |
0 ms |
0 KB |
- |