# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
50985 | Talant | Holiday (IOI14_holiday) | C++17 | 5012 ms | 5620 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"holiday.h"
#include <bits/stdc++.h>
#define fr first
#define sc second
#define mk make_pair
#define pb push_back
using namespace std;
const int N = (1e6 + 5);
long long ans;
int u[N];
multiset<int> st;
long long int findMaxAttraction(int n, int start, int d, int attraction[]) {
if (start == 0 && n > 3000) {
for (int i = 0; i < n; i ++) {
u[attraction[i]] ++;
int cn = d - i;
if (cn <= 0)
continue;
long long sum = 0;
for (int j = 100; j >= 1; j --) {
int o = min(u[j],cn);
sum += (o * 1ll * j);
cn -= o;
}
ans = max(ans,sum);
}
return ans;
}
else {
for (int i = 0; i <= start; i ++) {
st.clear();
long long sum = 0;
for (int j = i; j < n; j ++) {
st.insert(attraction[j]);
sum += attraction[j];
int dist = 0;
if (j <= start) dist = d - (start - i);
else if (start <= i) dist = d - (j - start);
else dist = d - ((abs(start - i) + abs(j - start)) + min(abs(start - i),abs(j - start)));
if (dist <= 0)
break;
while (!st.empty() && st.size() > dist) {
sum -= (*st.begin());
st.erase(st.begin());
}
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... |