# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
587143 | Jomnoi | Holiday (IOI14_holiday) | C++17 | 140 ms | 1712 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;
const int MAX_N = 1e5 + 5;
int N;
int A[MAX_N];
long long int findMaxAttraction(int n, int start, int d, int attraction[]) {
N = n;
for(int i = 0; i < N; i++) {
A[i] = attraction[i];
}
long long ans = 0;
if(N <= 3000) {
for(int l = 0; l <= start; l++) {
long long sum = 0;
priority_queue <int, vector <int>, greater <int>> pq;
for(int i = l; i < start; i++) {
sum += A[i];
pq.push(A[i]);
}
for(int r = start; r < N; r++) {
sum += A[r];
pq.push(A[r]);
while(pq.size() > max(0, d - (r - l) - min(start - l, r - start))) {
sum -= pq.top();
pq.pop();
}
ans = max(ans, sum);
}
}
}
else if(start == 0) {
long long sum = 0;
priority_queue <int, vector <int>, greater <int>> pq;
for(int i = 0; i < N; i++) {
sum += A[i];
pq.push(A[i]);
while(pq.size() > max(0, d - i)) {
sum -= pq.top();
pq.pop();
}
ans = max(ans, sum);
}
}
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... |