# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
50949 | Talant | Holiday (IOI14_holiday) | C++17 | 5028 ms | 988 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];
long long int findMaxAttraction(int n, int start, int d, int attraction[]) {
if (start == 0 && n > 20) {
for (int i = 0; i < n; i ++) {
u[attraction[i]] ++;
int cn = d - i;
if (cn <= 0)
continue;
long long sum = 0;
for (int i = 100; i >= 1; i --) {
int o = min(u[i],cn);
sum += (o * 1ll * i);
cn -= o;
}
ans = max(ans,sum);
}
return ans;
}
else {
for (int i = 1; i < (1 << n); i ++) {
int cn = __builtin_popcount(i);
int f = __builtin_ffs(i) - 1;
int s = (31 - __builtin_clz(i));
if (start <= f) {
if (s - start + cn > d)
continue;
}
else if (start >= s) {
if (start - f + cn > d)
continue;
}
else {
if ((s - start) + (start - f) + min((s - start),(start - f)) + cn > d)
continue;
}
long long sum = 0;
for (int j = 0; j < n; j ++) {
if (i & (1 << j))
sum += attraction[j];
}
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... |