Submission #15253

#TimeUsernameProblemLanguageResultExecution timeMemory
15253gs13068달리는 게임 (kriii3_E)C++98
26 / 70
2 ms1116 KiB
#include<cstdio> #include<algorithm> long long a[1111]; long long s[1111]; long long ss[1111]; long long d[1111]; int main() { int i,j,n; scanf("%d",&n); for(i=1;i<=n;i++)scanf("%lld",&a[i]); for(i=n;i>=0;i--) { s[i]=s[i+1]+a[i]; ss[i]=ss[i+1]+s[i+1]; d[i]=ss[i]; for(j=i+1;j<=n;j++)d[i]=std::max(d[i],d[j]+ss[i]-ss[j]-s[j]*(j-i)); } printf("%lld\n",d[0]); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...