답안 #15325

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
15325 2015-07-12T06:02:03 Z sujin 달리는 게임 (kriii3_E) C++
26 / 70
6 ms 16736 KB
#include <cstdio>

#define N 1000001
#define M 1001

int n,a[M];
long long s[N],q,mx[M],t[M][M];


int main ()
{
	int i,j;
	long long as;

	scanf ("%d",&n);
	for (i=1;i<=n;i++)
		scanf ("%d",a+i),s[i]=s[i-1]+a[i];

	for (i=1;i<=n;i++)
		for (j=i;j<=n;j++)
			t[i][j]=t[i][j-1]+a[j]*(j-i+1);
	for (i=1;i<=n;i++)
		for (j=1;j<=n;j++)
			if (mx[i]<t[j][i])
				mx[i]=t[j][i];

	for (i=1;i<=n;i++)
	{
		if (mx[i]<mx[i-1])
			mx[i]=mx[i-1];
		for (j=1;j<=i;j++)
			if (mx[i] < mx[j-1]+t[j][i])
				mx[i] = mx[j-1]+t[j][i];
	
	}
	printf ("%lld\n",mx[n]);
	
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 16736 KB Output is correct
2 Correct 3 ms 16736 KB Output is correct
3 Correct 6 ms 16736 KB Output is correct
4 Correct 6 ms 16736 KB Output is correct
5 Correct 3 ms 16736 KB Output is correct
6 Correct 3 ms 16736 KB Output is correct
7 Correct 3 ms 16736 KB Output is correct
8 Correct 6 ms 16736 KB Output is correct
9 Correct 6 ms 16736 KB Output is correct
10 Correct 3 ms 16736 KB Output is correct
11 Correct 6 ms 16736 KB Output is correct
12 Correct 3 ms 16736 KB Output is correct
13 Correct 3 ms 16736 KB Output is correct
14 Correct 3 ms 16736 KB Output is correct
15 Correct 3 ms 16736 KB Output is correct
16 Correct 0 ms 16736 KB Output is correct
17 Correct 3 ms 16736 KB Output is correct
18 Correct 6 ms 16736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 16732 KB futex (syscall #202) was called by the program (disallowed syscall)
2 Halted 0 ms 0 KB -