# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
15278 |
2015-07-12T05:15:36 Z |
ggoh |
달리는 게임 (kriii3_E) |
C++ |
|
0 ms |
32332 KB |
#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 time |
Memory |
Grader output |
1 |
Correct |
0 ms |
32332 KB |
Output is correct |
2 |
Incorrect |
0 ms |
32332 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Halted |
0 ms |
0 KB |
- |