Submission #13393

#TimeUsernameProblemLanguageResultExecution timeMemory
13393ggoh케이크 (JOI13_cake)C++98
0 / 100
0 ms32408 KiB
#include<cstdio> long long a,t,m,i,z[2002],D[2002][2002]; long long max(long long A,long long B) { return A>B?A:B; } long long mod(long long X) { return (X+a)%a; } long long f(long long x,long long y,long long cnt) { if(cnt==0)return 0; if(D[x][y])return D[x][y]; if((a-cnt)%2==1) { if(z[x]>z[y])return D[x][y]=f(mod(x-1),y,cnt-1); else return D[x][y]=f(x,mod(y+1),cnt-1); } else { return D[x][y]=max(z[x]+f(mod(x-1),y,cnt-1),z[y]+f(x,mod(y+1),cnt-1)); } } main() { scanf("%lld",&a); for(i=0;i<a;i++) { scanf("%lld",&z[i]); } for(i=0;i<a;i++) { t=z[i]+f(mod(i-1),mod(i+1),a-1); printf("%lld ",t); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...