# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
316260 | qpwoeirut | Holiday (IOI14_holiday) | C++17 | 5097 ms | 5496 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;
typedef long long ll;
ll findMaxAttraction(int n, int start, int d, int attraction[]) {
ll ans = 0;
for (int i=0; i<=start; ++i) {
multiset<ll> in;
ll sum = 0;
for (int j=i; j<n; ++j) {
in.insert(attraction[j]);
sum += attraction[j];
if (j >= start) {
ll travel = min((start - i) + (j - i), (j - start) + (j - i));
ll rem = d - travel;
if (rem <= 0) {
continue;
}
while (in.size() > rem) {
sum -= *in.begin();
in.erase(in.begin());
}
//cerr << "i,j,sum,rem: " << i << ' '<< j << ' ' << sum << ' ' << rem << endl;
//cerr << "in:"; for (auto it=in.begin(); it!=in.end(); ++it) { cerr << ' ' << *it; } cerr << endl;
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... |