# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
587127 | Jomnoi | Holiday (IOI14_holiday) | C++17 | 61 ms | 3188 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;
int maxAttraction = 0;
for(int i = 0; i < N; i++) {
A[i] = attraction[i];
maxAttraction = max(maxAttraction, A[i]);
}
long long ans = 0;
if(N <= 20) {
for(int mask = 0; mask < (1<<N); mask++) {
int lm = -1, rm = -1, cnt = 0;
long long sum = 0;
for(int i = 0; i < N; i++) {
if(mask & (1<<i)) {
if(lm == -1) {
lm = i;
}
rm = i;
cnt++;
sum += A[i];
}
}
if(rm - lm + min(abs(start - lm), abs(start - rm)) + cnt <= d) {
ans = max(ans, sum);
}
}
}
else if(maxAttraction <= 100 and start == 0) {
long long sum = 0;
priority_queue <int, vector <int>, greater <int>> pq;
for(int i = 0; i < d; i++) {
while(pq.size() >= d - i) {
sum -= pq.top();
pq.pop();
}
sum += A[i];
pq.push(A[i]);
ans = max(ans, sum);
}
}
else if(N <= 3000) {
// do something
}
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... |