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 i64 = long long;
template <class F, class S>
bool chmax(F &u, const S &v){
bool flag = false;
if ( u < v ){
u = v; flag |= true;
}
return flag;
}
long long int findMaxAttraction(int n, int s, int d, int attraction[]) {
vector <int> a(n);
for ( int i = 0; i < n; i++ ) a[i] = attraction[i];
i64 opt = 0;
for ( int mask = 1; mask < (1 << n); mask++ ){
int l = n, r = -1;
i64 cnt = 0;
for ( int i = 0; i < n; i++ ){
if ( mask >> i & 1 ){
cnt += a[i];
if ( l == n ) l = i;
r = i;
}
}
int x = __builtin_popcount(mask) + max(s, r) - min(l, s);
if ( l <= s && r >= s ) x += min(s - l, r - s);
chmax(opt, (x <= d) * cnt);
}
return opt;
}
# | 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... |