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;
using ll = long long;
long long int findMaxAttraction(int n, int start, int d, int attraction[]) {
ll res = 0;
vector<int> a(n);
for(int i = 0 ; i < n ; i++)
a[i] = attraction[i];
for(int mask = 1 ; mask < (1 << n) ; mask++) {
ll sum = 0, cost = 0;
int aa = n + 1, b = -1;
for(int i = 0 ; i < n ; i++)
if(mask & (1 << i)) {
sum += a[i];
cost++;
aa = min(aa, i);
b = max(b, i);
}
cost += (b - aa) + min(abs(start - aa), abs(start - b));
if(cost <= d)
res = max(res, sum);
}
return res;
}
# | 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... |