Submission #8146

# Submission time Handle Problem Language Result Execution time Memory
8146 2014-08-31T14:30:56 Z jhs7jhs 배열 탈출 (GA8_array) C++
100 / 100
640 ms 1120 KB
#include<stdio.h>

int d[2][2222]={0},a[2][2222]={0},n;
int min(int a,int b){if(a<b)return a;return b;}
int f(int a,int b){if(a>b)return 0;return b-a+1;}
int main()
{
	int i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			scanf("%d",&a[i%2][j]);
			if(!i && !j) continue;
			else if(!i) d[i%2][j] = d[i%2][j-1]+f(a[i%2][j-1],a[i%2][j]);
			else if(!j) d[i%2][j] = d[(i+1)%2][j]+f(a[(i+1)%2][j],a[i%2][j]);
			else d[i%2][j] = min(d[(i+1)%2][j]+f(a[(i+1)%2][j],a[i%2][j]),d[i%2][j-1]+f(a[i%2][j-1],a[i%2][j]));
		}
	}
	printf("%d",d[(n-1)%2][n-1]);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1120 KB Output is correct
2 Correct 0 ms 1120 KB Output is correct
3 Correct 0 ms 1120 KB Output is correct
4 Correct 0 ms 1120 KB Output is correct
5 Correct 0 ms 1120 KB Output is correct
6 Correct 0 ms 1120 KB Output is correct
7 Correct 0 ms 1120 KB Output is correct
8 Correct 0 ms 1120 KB Output is correct
9 Correct 0 ms 1120 KB Output is correct
10 Correct 0 ms 1120 KB Output is correct
11 Correct 0 ms 1120 KB Output is correct
12 Correct 0 ms 1120 KB Output is correct
13 Correct 0 ms 1120 KB Output is correct
14 Correct 0 ms 1120 KB Output is correct
15 Correct 0 ms 1120 KB Output is correct
16 Correct 0 ms 1120 KB Output is correct
17 Correct 0 ms 1120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1120 KB Output is correct
2 Correct 0 ms 1120 KB Output is correct
3 Correct 0 ms 1120 KB Output is correct
4 Correct 0 ms 1120 KB Output is correct
5 Correct 0 ms 1120 KB Output is correct
6 Correct 0 ms 1120 KB Output is correct
7 Correct 0 ms 1120 KB Output is correct
8 Correct 0 ms 1120 KB Output is correct
9 Correct 0 ms 1120 KB Output is correct
10 Correct 0 ms 1120 KB Output is correct
11 Correct 0 ms 1120 KB Output is correct
12 Correct 0 ms 1120 KB Output is correct
13 Correct 0 ms 1120 KB Output is correct
14 Correct 0 ms 1120 KB Output is correct
15 Correct 0 ms 1120 KB Output is correct
16 Correct 0 ms 1120 KB Output is correct
17 Correct 0 ms 1120 KB Output is correct
18 Correct 0 ms 1120 KB Output is correct
19 Correct 0 ms 1120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1120 KB Output is correct
2 Correct 4 ms 1120 KB Output is correct
3 Correct 4 ms 1120 KB Output is correct
4 Correct 8 ms 1120 KB Output is correct
5 Correct 8 ms 1120 KB Output is correct
6 Correct 4 ms 1120 KB Output is correct
7 Correct 4 ms 1120 KB Output is correct
8 Correct 4 ms 1120 KB Output is correct
9 Correct 4 ms 1120 KB Output is correct
10 Correct 4 ms 1120 KB Output is correct
11 Correct 4 ms 1120 KB Output is correct
12 Correct 0 ms 1120 KB Output is correct
13 Correct 4 ms 1120 KB Output is correct
14 Correct 8 ms 1120 KB Output is correct
15 Correct 4 ms 1120 KB Output is correct
16 Correct 4 ms 1120 KB Output is correct
17 Correct 8 ms 1120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 596 ms 1120 KB Output is correct
2 Correct 628 ms 1120 KB Output is correct
3 Correct 640 ms 1120 KB Output is correct
4 Correct 632 ms 1120 KB Output is correct
5 Correct 516 ms 1120 KB Output is correct
6 Correct 580 ms 1120 KB Output is correct
7 Correct 624 ms 1120 KB Output is correct
8 Correct 624 ms 1120 KB Output is correct
9 Correct 636 ms 1120 KB Output is correct
10 Correct 572 ms 1120 KB Output is correct
11 Correct 564 ms 1120 KB Output is correct
12 Correct 536 ms 1120 KB Output is correct
13 Correct 492 ms 1120 KB Output is correct
14 Correct 568 ms 1120 KB Output is correct
15 Correct 460 ms 1120 KB Output is correct
16 Correct 608 ms 1120 KB Output is correct
17 Correct 592 ms 1120 KB Output is correct
18 Correct 532 ms 1120 KB Output is correct
19 Correct 596 ms 1120 KB Output is correct
20 Correct 568 ms 1120 KB Output is correct
21 Correct 512 ms 1120 KB Output is correct