# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
50772 | Just_Solve_The_Problem | Holiday (IOI14_holiday) | C++11 | 352 ms | 996 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 <bits/stdc++.h>
#include"holiday.h"
using namespace std;
#define pb push_back
#define sz(s) (int)s.size()
#define ll long long
int cnt[123];
long long int findMaxAttraction(int n, int start, int d, int attraction[]) {
ll ans = 0;
if (n <= 20) {
for (int mask = 1; mask < (1 << n); mask++) {
vector < int > v;
for (int i = 0; i < n; i++) {
if (mask & (1 << i)) {
v.pb(i);
}
}
ll res = 0;
ll time = sz(v);
if (start > v.back() || start < v[0]) {
if (start > v.back()) {
time += abs(start - v[0]);
} else {
time += abs(start - v.back());
}
} else {
time += min(abs(start - v[0]), abs(start - v.back())) + v.back() - v[0];
}
for (int to : v) {
res += attraction[to];
}
if (time <= d) {
ans = max(ans, res);
}
}
} else if (start == 0) {
ll res;
for (int i = 0; i < n; i++) {
cnt[attraction[i]]++;
res = 0;
int cn = 0;
for (int j = 100; j >= 0; j--) {
if (i + cn + cnt[j] > d) {
res += (i + cn + cnt[j] - d) * j;
break;
} else {
res += cnt[j] * j;
}
cn += cnt[j];
}
ans = max(ans, res);
}
}
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... |