이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include"holiday.h"
#ifndef EVAL
#include "grader.cpp"
#endif
#include <bits/stdc++.h>
using namespace std;
#define lol long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scanl(a) scanf("%lld",&a);
#define scanll(a,b) scanf("%lld %lld",&a, &b);
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define scan1(a) scanf("%d",&a);
#define scan2(a,b) scanf("%d %d",&a, &b);
#define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
#define eps 1e-12
int N,strt,q[200001];
lol rec(int pos,int d,bool nap,lol sum=0){
if (pos < 0 || pos >= N)ret 0;
if (d == 1)ret (sum+q[pos]);
if (d < 0)ret 0;
if (d == 0)ret sum;
lol ans = 0;
if (nap){
ans = max(ans,rec(pos+1,d-1,1,sum));
ans = max(ans,rec(pos+1,d-2,1,sum+q[pos]));
ans = max(ans,rec(strt-1,d-abs(pos-strt)-1,0,sum));
ans = max(ans,rec(strt-1,d-abs(pos-strt)-2,0,sum+q[pos]));
}
else {
ans = max(ans,rec(pos-1,d-1,0,sum));
ans = max(ans,rec(pos-1,d-2,0,sum+q[pos]));
}
ret ans;
}
lol int findMaxAttraction(int n, int start, int d, int attraction[]) {
for (int i=0;i<n;++i)q[i] = attraction[i];
N = n;
strt = start;
ret (rec(start,d,1));
}
# | 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... |