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<algorithm>
#include<iostream>
#include<vector>
#include<set>
using namespace std;
using ll = long long;
const int N = 222;
const int D = 2*N + N/2;
ll sum = 0;
multiset<ll>st;
ll findMaxAttraction(int n, int start, int d, int attraction[]) {
ll ans = 0;
for (int _ = 0 ; _ < 2 ; ++ _) {
for (int i = start ; i < n ; ++ i) {
int x = d - (i - start);
st.clear();
sum = 0;
for (int j = i ; j >= 0 ; -- j) {
sum += attraction[j];
st.insert(attraction[j]);
int y = x - (i - j);
if (y < 0) break;
while ((int)st.size() > y) {
sum -= *st.begin();
st.erase(st.begin());
}
ans = max(ans, sum);
}
}
reverse(attraction, attraction + n);
start = n - start - 1;
}
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... |