Submission #417791

#TimeUsernameProblemLanguageResultExecution timeMemory
417791vanicHoliday (IOI14_holiday)C++14
47 / 100
5100 ms1300 KiB
#include "holiday.h"
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;

priority_queue < int, vector < int >, greater < int >  > q;

ll findMaxAttraction(int n, int x, int d, int l[]){
	int treba;
	ll sum=0, sol=0;
	for(int i=0; i<=x; i++){
		treba=x-i;
		if(treba>=d){
			continue;
		}
		for(int j=i; j<=x; j++){
			q.push(l[j]);
			sum+=l[j];
		}
		while(!q.empty() && d-treba<(int)q.size()){
			sum-=q.top();
			q.pop();
		}
		sol=max(sol, sum);
		for(int j=x+1; j<n; j++){
			treba=min(j-x, x-i)*2+max(j-x, x-i);
			sum+=l[j];
			q.push(l[j]);
			while(!q.empty() && d-treba<(int)q.size()){
				sum-=q.top();
				q.pop();
			}
			sol=max(sol, sum);
		}
		while(!q.empty()){
			q.pop();
		}
		sum=0;
	}
	return sol;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...