Submission #417786

#TimeUsernameProblemLanguageResultExecution timeMemory
417786vanicHoliday (IOI14_holiday)C++14
23 / 100
5044 ms6152 KiB
#include "holiday.h" #include <cmath> #include <algorithm> #include <set> using namespace std; typedef long long ll; ll findMaxAttraction(int n, int x, int d, int l[]){ multiset < int > s; 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++){ s.insert(l[j]); sum+=l[j]; } while(d-treba<(int)s.size()){ sum-=*s.begin(); s.erase(s.begin()); } 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]; s.insert(l[j]); while(d-treba<(int)s.size()){ sum-=*s.begin(); s.erase(s.begin()); } sol=max(sol, sum); } s.clear(); 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...