# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
58620 | aome | Holiday (IOI14_holiday) | C++17 | 5009 ms | 4384 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;
long long int findMaxAttraction(int n, int start, int d, int attraction[]) {
int cur = d;
long long res = 0;
long long sum = 0;
priority_queue< int, vector<int>, greater<int> > pq;
for (int i = start; i >= 0; --i) {
sum += attraction[i], pq.push(attraction[i]);
while (pq.size() && pq.size() > cur) {
sum -= pq.top(), pq.pop();
}
res = max(res, sum);
cur--;
}
while (pq.size()) pq.pop();
for (int i = start; i >= 0; --i) {
cur = d - (start - i);
sum = 0;
for (int j = i; j < n; ++j) {
sum += attraction[j], pq.push(attraction[j]);
while (pq.size() && pq.size() > cur) {
sum -= pq.top(), pq.pop();
}
res = max(res, sum);
cur--;
}
while (pq.size()) pq.pop();
}
return res;
}
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... |