# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1064685 | NemanjaSo2005 | Holiday (IOI14_holiday) | C++17 | 5008 ms | 2520 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"holiday.h"
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+5;
int N,niz[maxn],best[maxn],val[maxn],D;
priority_queue<int> PQ;
ll suma,res=0;
long long int findMaxAttraction(int n, int start, int ddd, int attraction[]) {
N=n;
for(int i=1;i<=N;i++)
niz[i]=attraction[i-1];
D=ddd;
start++;
for(int i=1;i<=N;i++)
best[i]=start;
for(int i=start;i>=1;i--){
suma=0;
while(PQ.size())
PQ.pop();
for(int j=i;j<start;j++){
suma+=niz[j];
PQ.push(-niz[j]);
}
for(int j=start;j<=N;j++){
int d=j-i+min(start-i,j-start);
if(d>=D)
break;
suma+=niz[j];
PQ.push(-niz[j]);
while(PQ.size()+d>D){
suma+=PQ.top();
PQ.pop();
}
if(suma>=val[j]){
val[j]=suma;
best[j]=i;
}
res=max(res,suma);
}
}
for(int i=start+1;i<=N;i++)
if(best[i]<best[i-1])
exit(-1);
return res;
}
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... |