# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
114420 | E869120 | Holiday (IOI14_holiday) | C++14 | 19 ms | 1152 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>
using namespace std;
long long e[109];
long long int findMaxAttraction(int n, int start, int d, int attraction[]) {
if (n <= 300) {
long long maxn = 0;
for (int i = 0; i <= start; i++) {
for (int j = start; j < n; j++) {
vector<long long> E; for (int k = i; k <= j; k++) E.push_back(attraction[k]);
sort(E.begin(), E.end());
reverse(E.begin(), E.end());
int J = d - (j - i) - min(start - i, j - start);
long long sum = 0;
for (int k = 0; k < E.size(); k++) {
if (J <= k) break;
sum += E[k];
}
maxn = max(maxn, sum);
}
}
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)
# | 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... |