# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
782180 | I_Love_EliskaM_ | Holiday (IOI14_holiday) | C++14 | 5068 ms | 2388 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>
using namespace std;
#define forn(i,n) for(int i=0;i<n;++i)
#define pb push_back
#define all(x) x.begin(),x.end()
#define pi pair<int,int>
#define f first
#define s second
using ll = long long;
const int inf=1e9;
ll findMaxAttraction(int n, int s, int d, int b[]) {
vector<int> a(n); forn(i,n) a[i]=b[i];
ll ans=0;
int D=d;
for (int l=s; l>=0; --l) {
if (!d) break;
ll sum=0;
priority_queue<int> q;
for (int j=l; j<min(l+d,n); ++j) {
sum+=a[j];
q.push(-a[j]);
while (q.size()+j-l > d) {
sum+=q.top();
q.pop();
}
ans=max(ans,sum);
}
--d;
}
if (s==0) return ans;
reverse(all(a)); s=n-1-s;
d=D;
for (int l=s; l>=0; --l) {
if (!d) break;
ll sum=0;
priority_queue<int> q;
for (int j=l; j<min(l+d,n); ++j) {
sum+=a[j];
q.push(-a[j]);
while (q.size()+j-l > d) {
sum+=q.top();
q.pop();
}
ans=max(ans,sum);
}
--d;
}
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... |