This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
#define INF 2001001001
#define MOD 1000000007
ll ans;
ll findMaxAttraction(int N, int S, int D, int arr[]){
{
multiset<ll>mst;
ll sum=0;
for (int i=S;i<N;i++){
mst.insert(arr[i]);
sum+=arr[i];
while ((int)mst.size()>D-(i-S)){
sum-=*mst.begin();
mst.erase(mst.find(*mst.begin()));
}
ans=max(ans,sum);
}
}
{
multiset<ll>mst;
ll sum=0;
for (int i=S;i>=0;i--){
mst.insert(arr[i]);
sum+=arr[i];
while ((int)mst.size()>D-(S-i)){
sum-=*mst.begin();
mst.erase(mst.find(*mst.begin()));
}
ans=max(ans,sum);
}
}
if (S==0){
return ans;
return 0;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |