Submission #361908

#TimeUsernameProblemLanguageResultExecution timeMemory
361908beksultan04Holiday (IOI14_holiday)C++14
7 / 100
5097 ms8952 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 || 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,d-abs(pos-strt),0,sum)); ans = max(ans,rec(strt,d-abs(pos-strt)-1,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+1; 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...