# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
749934 | Abrar_Al_Samit | Holiday (IOI14_holiday) | C++17 | 5045 ms | 6292 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;
long long int findMaxAttraction(int n, int start, int d, int a[]) {
multiset<int>list;
long long ans = 0;
long long cur = 0;
for(int i=0; i<n; ++i) {
if(i+list.size()>d) {
cur -= *list.begin();
list.erase(list.begin());
}
if(i+list.size()<d) {
list.insert(a[i]);
cur += a[i];
} else {
if(!list.empty() && *list.begin()<a[i]) {
cur -= *list.begin();
list.erase(list.begin());
list.insert(a[i]);
cur += a[i];
}
}
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... |