Submission #15278

#TimeUsernameProblemLanguageResultExecution timeMemory
15278ggoh달리는 게임 (kriii3_E)C++98
0 / 70
0 ms32332 KiB
#include<cstdio> #include<algorithm> #include<vector> #include<cmath> long long a,i,j,m,M,dp[1000006],x[1000006],p[1000006],b[1000006]; main() { scanf("%lld",&a); for(i=1;i<=a;i++)scanf("%lld",&x[i]); for(i=1;i<=a;i++)p[i]=p[i-1]+i*x[i],b[i]=b[i-1]+x[i]; dp[0]=0; for(i=1;i<=a+1;i++) { M=-1e18; for(j=i-1;j>=0;j--) { M=std::max(M,dp[j]-j*(b[i-1]-b[j])-p[j]); } dp[i]=M+p[i-1]; m=std::max(dp[i],m); } printf("%d",m); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...