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;
ll findMaxAttraction(int n, int start, int d, int attraction[]) {
ll ans = 0;
for (int i = 0; i < (1 << n); i++) {
vector <int> vis;
ll tp = 0;
for (int j = 0; j < n; j++) {
if (i & (1 << j)) {
vis.push_back(j);
tp += attraction[j];
}
}
int days1 = 0, days2 = 0;
if (!vis.empty()) {
if (vis[0] < start)
days1 = start - vis[0];
int lst = 0;
for (auto j : vis) {
if (j <= start)
days1++;
else {
if (lst <= start)
days1 += vis.back() - min(vis[0], start);
days1++;
}
lst = j;
}
if (vis.back() > start)
days2 = vis.back() - start;
lst = n;
reverse(vis.begin(), vis.end());
for (auto j : vis) {
if (j >= start)
days2++;
else {
if (lst >= start)
days2 += max(vis[0], start) - vis.back();
days2++;
}
lst = j;
}
if (min(days1, days2) <= d)
ans = max(ans, tp);
}
}
return ans;
}
// int main() {
// int n, st, d;
// cin >> n >> st >> d;
// int a[n];
// for (int i = 0; i < n; i++)
// cin >> a[i];
// cout << findMaxAttraction(n, st, d, a) << '\n';
// }
# | 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... |