이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "holiday.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define forn(j, i, n) for(int i = j; i <= n; ++i)
#define FOR(j, i, n) for(int i = j; i < n; ++i)
#define nfor(j, i, n) for(int i = n; i >= j; --i)
#define IOS ios_base::sync_with_stdio(false), cin.tie(), cout.tie();
#define all(v) v.begin(), v.end()
const int maxn = 7e3+100;
//#define int ll
#define pii pair <int, int>
int inf = 1e9;
ll a[maxn];
long long int findMaxAttraction(int n, int start, int d, int attraction[])
{
forn(0, i, n-1)
{
a[i] = attraction[i];
}
ll ans = 0;
forn(0, mask, (1 << n) - 1)
{
int right = start;
int left = start;
ll s = 0;
int cnt = 0;
forn(0, i, n-1)
{
if(((mask>>i)&1))
{
if(i >= start) right = max(right, i);
else left = min(left, i);
s += a[i];
cnt++;
}
}
if(cnt + right-left + min(right-start,start-left) <= d)
{
ans = max(ans, s);
}
}
return ans;
}
/*
int main() {
int n, start, d;
int attraction[100000];
int i, n_s;
n_s = scanf("%d %d %d", &n, &start, &d);
for (i = 0 ; i < n; ++i) {
n_s = scanf("%d", &attraction[i]);
}
printf("%lld\n", findMaxAttraction(n, start, d, attraction));
return 0;
}*/
# | 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... |