# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
749950 | Abrar_Al_Samit | Holiday (IOI14_holiday) | C++17 | 5029 ms | 5324 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;
int get(int i, int j, int x) {
return j-i + min(x-i, j-x);
}
long long int findMaxAttraction(int n, int start, int d, int a[]) {
if(d==0) return 0;
long long ans = 0;
for(int i=0; i<=start; ++i) {
if(start-i>d) continue;
multiset<int>list;
long long cur = 0;
for(int j=i; j<start; ++j) {
list.insert(a[j]);
cur += a[j];
}
while(list.size()+start-i>d) {
cur -= *list.begin();
list.erase(list.begin());
}
for(int j=start; j<n && get(i, j, start)<d; ++j) {
int travel_cost = get(i, j, start);
if(travel_cost+list.size()>d) {
cur -= *list.begin();
list.erase(list.begin());
}
if(travel_cost+list.size()>d) {
cur -= *list.begin();
list.erase(list.begin());
}
if(travel_cost+list.size()<d) {
list.insert(a[j]);
cur += a[j];
} else {
if(a[j]>*list.begin()) {
cur -= *list.begin();
list.erase(list.begin());
cur += a[j];
list.insert(a[j]);
}
}
ans = max(ans, cur);
}
}
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... |