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 ll long long
#define pb push_back
#define pp pop_back
#define mp make_pair
#define bb back
#define ff first
#define ss second
using namespace std;
long long int findMaxAttraction(int n, int start, int d, int attraction[]) {
ll ans = 0, D = d;
for (ll state = 1; state < (1 << n); state++) {
ll l = -1, r = 0, cnt = 0, now = 0;
for (ll i = 0; i < n; i++) {
if (state & (1 << i)) {
if (l == -1) l = i;
r = i;
cnt++;
now += attraction[i];
}
}
if (l >= start) {
if (r-start+cnt <= D)
ans = max(ans, now);
} else if (r <= start) {
if (start-l+cnt <= D)
ans = max(ans, now);
} else {
if (min(abs(start-l)*2+abs(start-r), abs(start-r)*2+abs(start-l))+cnt <= D)
ans = max(ans, now);
}
}
return ans;
}
# | 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... |