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;
long long e[109];
long long int findMaxAttraction(int n, int start, int d, int attraction[]) {
if (n <= 3000) {
long long maxn = 0;
for (int i = 0; i <= start; i++) {
priority_queue<long long, vector<long long>, greater<long long>>Q; long long s = 0;
for (int j = i; j <= start - 1; j++) {
Q.push(attraction[j]); s += 1LL * attraction[j];
while (!Q.empty() && (int)Q.size() > d - (start - i)) { s -= Q.top(); Q.pop(); }
}
for (int j = start; j < n; j++) {
s += attraction[j];
Q.push(attraction[j]);
int J = d - (j - i) - min(start - i, j - start);
while (!Q.empty() && (int)Q.size() > J) { s -= Q.top(); Q.pop(); }
maxn = max(maxn, s);
}
}
return maxn;
}
long long maxn = 0;
for (int i = 0; i < n; i++) {
e[attraction[i]]++;
long long s = 0, rem = d - i;
for (int j = 100; j >= 0; j--) {
if (rem >= e[j]) { rem -= e[j]; s += 1LL * e[j] * j; }
else { s += 1LL * rem * j; rem = 0; }
}
maxn = max(maxn, s);
}
return maxn;
}
Compilation message (stderr)
grader.cpp: In function 'int main()':
grader.cpp:7:12: warning: variable 'n_s' set but not used [-Wunused-but-set-variable]
int i, n_s;
^~~
# | 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... |