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 "holiday.h"
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e5;
int a[N];
ll findMaxAttraction(int n, int start, int d, int att[]) {
for(int i=0;i<n;i++){
a[i] = att[i];
}
ll ans = 0;
if(start==0){
priority_queue<ll> q;
multiset<ll> s;
ll sum = 0;
int mid = min(n, (d+1)/2);
if(d%2==0&&mid!=n)mid++;
for(int i=0;i<mid;i++){
s.insert(a[i]);
sum += a[i];
}ans = sum;
if(d%2==0&&mid!=n){
auto x = s.begin();sum -= *x;
s.erase(x);
}
for(int i=mid;i<min(d, n);i++){
auto f = s.begin();
sum -= *f;q.push(*f); s.erase(f);
ll mn = *s.begin();
q.push(a[i]);
ll mx = q.top();
if(mn < mx){
s.erase(s.find(mn));sum-=mn;
sum += mx;q.pop();
s.insert(mx);
}
ans = max(sum, ans);
}
}else {
cout << "I HAVE NO IDEA HOW TO SOLVE IT" << endl;
ans = (ll)892347238923847;
}
return ans;
}
# | 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... |