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 "holiday.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
int findMaxAttraction(int32_t n, int32_t S, int32_t d, int32_t a[]) {
int l = 0, r = S;
int ans = 0;
while (l <= S && r<n) {
int k = min(d - (r-l) - min(S-l, r-S), r-l+1);
// cout << l << " " << r << " " << k << endl;
vector<pair<int,int>> v;
for (int i=l;i<=r;i++) v.push_back({a[i], i});
sort(v.rbegin(), v.rend());
int curans = 0, leftmost = 1e9;
for (int i=0;i<k;i++) {
curans += v[i].first;
leftmost = min(v[i].second, leftmost);
}
// cout << l << " " << r << " " << curans << " " << leftmost << endl;
ans = max(curans, ans);
if (l==leftmost || l==S) r++;
else l++;
}
return ans;
}
# | 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... |