Submission #587057

#TimeUsernameProblemLanguageResultExecution timeMemory
587057krit3379Holiday (IOI14_holiday)C++17
47 / 100
361 ms1740 KiB
#include<bits/stdc++.h> #include"holiday.h" using namespace std; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #define N 100005 long long sum,ans; priority_queue<long long,vector<long long>,greater<long long>> q; void add(long long x){ q.push(x); sum+=x; } void upd(int k){ while(!q.empty()&&(int)q.size()>k){ sum-=q.top(); q.pop(); } } long long int findMaxAttraction(int n,int st,int d,int a[]){ int i,j; if(n<=3000){ for(i=0;i<=st;i++){ sum=0; for(j=i;j<st;j++)add(a[j]); for(j=st;j<n;j++){ add(a[j]); upd(d-j+i-min(st-i,j-st)); ans=max(ans,sum); } while(!q.empty())q.pop(); } } else if(st==0){ sum=0; for(i=0;i<n;i++){ add(a[i]); upd(d-i); ans=max(ans,sum); } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...