# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
915323 | Trisanu_Das | Holiday (IOI14_holiday) | C++17 | 0 ms | 0 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 <bits/stdc++.h>
#include "holiday.h"
using namespace std;
long long findMaxAttraction(int n, int s, int d, int a[]) {
long long ans = 0;
for(int l = 0; l <= st; l++) {
priority_queue<long long, vector<long long>, greater<long long> > pq;
long long curr = 0;
for (int r = l; r < n; r++) {
curr += a[r];
pq.push(a[r]);
int sm = min(abs(r - s), abs(l - s)) + r - l;
sm = d - sm;
if(sm < 0) continue;
while(pq.size() > sm) curr -= pq.top(), pq.pop();
ans = max(ans, curr);
}
}
return ans;
}