# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
584955 | Mazaalai | Holiday (IOI14_holiday) | C++17 | 5036 ms | 5560 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"
#define ALL(x) x.begin(),x.end()
#define LLA(x) x.rbegin(),x.rend()
#define pb push_back
using namespace std;
using PII = pair <int, int>;
using ll = long long;
long long int findMaxAttraction(int n, int start, int d, int nums[]) {
ll ans = 0;
for (int i = start; i >= 0; i--) {
int l = start - i;
multiset <int> vals;
ll sum = 0;
for (int p = i; p <= start; p++) {
vals.insert(nums[p]);
sum += nums[p];
}
// cout << i+1 << "," << start+1 << ": ";
// for (auto el : vals) cout << el << ' '; cout << '\n';
for (int j = start+1; j < n; j++) {
int r = j - start;
int move = l + r + min(l, r);
int need = d - move;
if (need <= 0) break;
vals.insert(nums[j]);
sum += nums[j];
while(need < vals.size()) {
sum -= *vals.begin();
vals.erase(vals.begin());
}
// cout << i+1 << "," << j+1 << ": ";
// for (auto el : vals) cout << el << ' '; cout << '\n';
ans = max(ans, sum);
}
}
// cout << "\n";
// for(int i = 0; i < n; i++) cout << nums[i] << " \n"[i==n-1];
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... |