# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
675500 | bashkort | Holiday (IOI14_holiday) | C++17 | 5085 ms | 2364 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;
using ll = long long;
ll solve(int n, int start, int d, int attraction[]) {
priority_queue<int, vector<int>, greater<>> pq;
ll ans = 0, sum = 0;
for (int i = start; i < n; ++i) {
pq.push(attraction[i]);
sum += attraction[i];
while (!pq.empty() && pq.size() + (i - start) > d) {
sum -= pq.top();
pq.pop();
}
ans = max(ans, sum);
}
return ans;
}
ll findMaxAttraction(int n, int start, int d, int attraction[]) {
ll ans = 0;
if (start == 0) {
return solve(n, start, d, attraction);
} else {
for (int _ = 0; _ < 2; ++_) {
for (int i = 0; i <= start; ++i) {
if (start - i < d) {
ans = max(ans, solve(n, i, d - (start - i), attraction));
}
}
reverse(attraction, attraction + n);
start = n - start - 1;
}
}
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... |