Submission #15285

# Submission time Handle Problem Language Result Execution time Memory
15285 2015-07-12T05:20:56 Z ggoh 달리는 게임 (kriii3_E) C++
26 / 70
1000 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("%lld",m);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 32332 KB Output is correct
2 Correct 2 ms 32332 KB Output is correct
3 Correct 2 ms 32332 KB Output is correct
4 Correct 0 ms 32332 KB Output is correct
5 Correct 0 ms 32332 KB Output is correct
6 Correct 2 ms 32332 KB Output is correct
7 Correct 0 ms 32332 KB Output is correct
8 Correct 0 ms 32332 KB Output is correct
9 Correct 0 ms 32332 KB Output is correct
10 Correct 0 ms 32332 KB Output is correct
11 Correct 0 ms 32332 KB Output is correct
12 Correct 0 ms 32332 KB Output is correct
13 Correct 0 ms 32332 KB Output is correct
14 Correct 0 ms 32332 KB Output is correct
15 Correct 2 ms 32332 KB Output is correct
16 Correct 2 ms 32332 KB Output is correct
17 Correct 0 ms 32332 KB Output is correct
18 Correct 2 ms 32332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1000 ms 32328 KB Program timed out
2 Halted 0 ms 0 KB -