제출 #361907

#제출 시각아이디문제언어결과실행 시간메모리
361907beksultan04Holiday (IOI14_holiday)C++14
0 / 100
5077 ms8940 KiB
#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 sum; 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...