# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
50493 | mirbek01 | Holiday (IOI14_holiday) | C++17 | 88 ms | 1104 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;
const int N = 1e5 + 2;
int n, cnt[N];
long long int findMaxAttraction(int N, int start, int d, int attraction[]) {
n = N;
int fl = 1;
long long ans = 0;
for(int i = 0; i < n; i ++)
if(attraction[i] > 100) fl = 0;
if(!start && fl){
for(int i = 0; i < n; i ++){
cnt[attraction[i]] ++;
long long res = 0;
if(i < d){
int now = d - i;
for(int i = 100; i >= 0; i --){
if(now >= cnt[i]){
res += cnt[i] * i;
now -= cnt[i];
} else {
res += now * i;
now = 0;
}
}
}
ans = max(ans, res);
}
} else {
if(n <= 20){
for(int mask = 1; mask < (1 << n); mask ++){
int kol = 0;
long long res = 0, l, r;
for(int i = 0; i < n; i ++){
int bit = (1 << i) & mask;
if(bit){
res += attraction[i];
if(l == -1) l = i;
r = i;
kol ++;
}
}
kol += min( max(0ll, start - l) * 2 + max(0ll, r - start), max(0ll, start - l) + max(0ll, r - start) * 2 );
if(kol <= d) 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... |