This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
#include "holiday.h"
ll findMaxAttraction(int N, int start, int D, int attraction[]) {
vi a;
for (int i = 0; i < N; i++) {
a.pb(attraction[i]);
}
ll maximum = 0;
for (int i = 1; i < (1 << N); i++) { // get this subset
ll total = 0;
int lb = N + 1;
int ub = -1;
int cnt = 0;
for (int j = 0; j < N; j++) {
if (i & (1 << j)) {
lb = min(lb, j);
ub = max(ub, j);
total += a[j];
cnt++;
}
}
int days = (start - lb) + (ub - start) + min(start - lb, ub - start);
if (lb <= ub && ub <= start)
days = start - lb;
if (start <= lb && lb <= ub)
days = ub - start;
days += cnt;
if (days <= D)
maximum = max(maximum, total);
}
return maximum;
}
# | 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... |