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>
using namespace std;
const int MAXN = 2e5;
typedef long long int ll;
int f[MAXN];
long long int findMaxAttraction(int n, int start, int d, int a[]) {
ll ans = 0;
priority_queue<int,vector<int>,greater<int>>pq;
int cost = -1;
ll sum = 0;
if(start == 0){
for(int i=0;i<n;i++){
cost++;
sum+=a[i];
pq.push(a[i]);
cost++;
while(!pq.empty() && cost > d){
cost--;
sum-=pq.top();
pq.pop();
}
if(cost > d)break;
ans = max(ans,sum);
//cout<<cost<<" "<<pq.size()<<'\n';
}
}
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... |