# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
122166 | brcode | Holiday (IOI14_holiday) | C++14 | 5012 ms | 2956 KiB |
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 <iostream>
#include <queue>
#include <holiday.h>
using namespace std;
long long int findMaxAttraction(int n, int start, int d,int attraction[]){
if(start == 0){
priority_queue<long long> pq;
long long sum = 0;
long long ans = 0;
for(long long i=0;i<n;i++){
pq.push(-1*attraction[i]);
sum+=attraction[i];
while(pq.size()+i>d){
long long hold = pq.top();
sum+=hold;
pq.pop();
}
ans= max(sum,ans);
}
return ans;
}else{
long long ans = 0;
for(long long l=0;l<=start;l++){
priority_queue<long long> pq;
long long sum = 0;
for(long long i=l;i<start;i++){
pq.push(-1*attraction[i]);
sum+=attraction[i];
}
for(long long r=start;r<n;r++){
if(r-l>=d){
break;
}
pq.push(-1*attraction[r]);
sum+=attraction[r];
while(pq.size() && pq.size()+(r-l)+min(start-l,r-start)>d){
long long hold = pq.top();
sum+=hold;
pq.pop();
}
ans = max(ans,sum);
}
}
return ans;
}
}
Compilation message (stderr)
# | 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... |