답안 #7729

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
7729 2014-08-17T02:58:06 Z ggoh 배열 탈출 (GA8_array) C++
100 / 100
676 ms 39696 KB
#include<cstdio>
int a,i,j,x,y,z[2223][2223],D[2223][2223];
int min(int A,int B)
{
	if(A>B)return B;
	else return A;
}
main()
{
	scanf("%d",&a);
	for(i=1;i<=a;i++)
	{
		for(j=1;j<=a;j++)
		{
			scanf("%d",&z[i][j]);
		}
	}
	for(i=2;i<=a;i++)
	{
		if(z[i][1]>=z[i-1][1])
		{
			D[i][1]=D[i-1][1]+z[i][1]-z[i-1][1]+1;
		}
		else
		{
			D[i][1]=D[i-1][1];
		}
		if(z[1][i]>=z[1][i-1])
		{
			D[1][i]=D[1][i-1]+z[1][i]-z[1][i-1]+1;
		}
		else
		{
			D[1][i]=D[1][i-1];
		}
	}
	for(i=2;i<=a;i++)
	{
		for(j=2;j<=a;j++)
		{
			if(z[i][j]>=z[i][j-1])
			{
				x=z[i][j]-z[i][j-1]+1;
			}
			else x=0;
			if(z[i][j]>=z[i-1][j])
			{
				y=z[i][j]-z[i-1][j]+1;
			}
			else y=0;
			D[i][j]=min(D[i][j-1]+x,D[i-1][j]+y);
		}
	}
	printf("%d",D[a][a]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 39696 KB Output is correct
2 Correct 0 ms 39696 KB Output is correct
3 Correct 0 ms 39696 KB Output is correct
4 Correct 0 ms 39696 KB Output is correct
5 Correct 0 ms 39696 KB Output is correct
6 Correct 0 ms 39696 KB Output is correct
7 Correct 0 ms 39696 KB Output is correct
8 Correct 0 ms 39696 KB Output is correct
9 Correct 0 ms 39696 KB Output is correct
10 Correct 0 ms 39696 KB Output is correct
11 Correct 0 ms 39696 KB Output is correct
12 Correct 0 ms 39696 KB Output is correct
13 Correct 0 ms 39696 KB Output is correct
14 Correct 0 ms 39696 KB Output is correct
15 Correct 0 ms 39696 KB Output is correct
16 Correct 0 ms 39696 KB Output is correct
17 Correct 0 ms 39696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 39696 KB Output is correct
2 Correct 0 ms 39696 KB Output is correct
3 Correct 0 ms 39696 KB Output is correct
4 Correct 0 ms 39696 KB Output is correct
5 Correct 0 ms 39696 KB Output is correct
6 Correct 0 ms 39696 KB Output is correct
7 Correct 0 ms 39696 KB Output is correct
8 Correct 0 ms 39696 KB Output is correct
9 Correct 0 ms 39696 KB Output is correct
10 Correct 0 ms 39696 KB Output is correct
11 Correct 0 ms 39696 KB Output is correct
12 Correct 0 ms 39696 KB Output is correct
13 Correct 0 ms 39696 KB Output is correct
14 Correct 0 ms 39696 KB Output is correct
15 Correct 0 ms 39696 KB Output is correct
16 Correct 0 ms 39696 KB Output is correct
17 Correct 0 ms 39696 KB Output is correct
18 Correct 0 ms 39696 KB Output is correct
19 Correct 0 ms 39696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 39696 KB Output is correct
2 Correct 8 ms 39696 KB Output is correct
3 Correct 8 ms 39696 KB Output is correct
4 Correct 8 ms 39696 KB Output is correct
5 Correct 8 ms 39696 KB Output is correct
6 Correct 8 ms 39696 KB Output is correct
7 Correct 8 ms 39696 KB Output is correct
8 Correct 8 ms 39696 KB Output is correct
9 Correct 4 ms 39696 KB Output is correct
10 Correct 8 ms 39696 KB Output is correct
11 Correct 8 ms 39696 KB Output is correct
12 Correct 4 ms 39696 KB Output is correct
13 Correct 0 ms 39696 KB Output is correct
14 Correct 8 ms 39696 KB Output is correct
15 Correct 4 ms 39696 KB Output is correct
16 Correct 8 ms 39696 KB Output is correct
17 Correct 8 ms 39696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 656 ms 39696 KB Output is correct
2 Correct 676 ms 39696 KB Output is correct
3 Correct 656 ms 39696 KB Output is correct
4 Correct 664 ms 39696 KB Output is correct
5 Correct 528 ms 39696 KB Output is correct
6 Correct 580 ms 39696 KB Output is correct
7 Correct 652 ms 39696 KB Output is correct
8 Correct 640 ms 39696 KB Output is correct
9 Correct 644 ms 39696 KB Output is correct
10 Correct 592 ms 39696 KB Output is correct
11 Correct 588 ms 39696 KB Output is correct
12 Correct 560 ms 39696 KB Output is correct
13 Correct 480 ms 39696 KB Output is correct
14 Correct 576 ms 39696 KB Output is correct
15 Correct 468 ms 39696 KB Output is correct
16 Correct 588 ms 39696 KB Output is correct
17 Correct 608 ms 39696 KB Output is correct
18 Correct 568 ms 39696 KB Output is correct
19 Correct 592 ms 39696 KB Output is correct
20 Correct 604 ms 39696 KB Output is correct
21 Correct 520 ms 39696 KB Output is correct