Submission #7890

# Submission time Handle Problem Language Result Execution time Memory
7890 2014-08-23T13:33:20 Z Qwaz 배열 탈출 (GA8_array) C++14
100 / 100
612 ms 42416 KB
#include <cstdio>
#include <algorithm>

using namespace std;
const int MAX = 2300, INF = 1234567890;

int n, map[MAX][MAX];

void input(){
	scanf("%d", &n);

	int i, j;
	for(i = 1; i<=n; i++){
		for(j = 1; j<=n; j++){
			scanf("%d", &map[i][j]);
		}
	}
}

int cost[MAX][MAX];

void solve(){
	int i, j;
	for(i = 1; i<=n; i++){
		for(j = 1; j<=n; j++){
			if(i == 1 && j == 1) continue;

			cost[i][j] = INF;
			if(i > 1) cost[i][j] = min(cost[i][j], cost[i-1][j]+max(0, map[i][j]-map[i-1][j]+1));
			if(j > 1) cost[i][j] = min(cost[i][j], cost[i][j-1]+max(0, map[i][j]-map[i][j-1]+1));
		}
	}

	printf("%d\n", cost[n][n]);
}

int main(){
	input();

	solve();

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 42416 KB Output is correct
2 Correct 0 ms 42416 KB Output is correct
3 Correct 0 ms 42416 KB Output is correct
4 Correct 0 ms 42416 KB Output is correct
5 Correct 0 ms 42416 KB Output is correct
6 Correct 0 ms 42416 KB Output is correct
7 Correct 0 ms 42416 KB Output is correct
8 Correct 0 ms 42416 KB Output is correct
9 Correct 0 ms 42416 KB Output is correct
10 Correct 0 ms 42416 KB Output is correct
11 Correct 0 ms 42416 KB Output is correct
12 Correct 0 ms 42416 KB Output is correct
13 Correct 0 ms 42416 KB Output is correct
14 Correct 0 ms 42416 KB Output is correct
15 Correct 0 ms 42416 KB Output is correct
16 Correct 0 ms 42416 KB Output is correct
17 Correct 0 ms 42416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 42416 KB Output is correct
2 Correct 0 ms 42416 KB Output is correct
3 Correct 0 ms 42416 KB Output is correct
4 Correct 0 ms 42416 KB Output is correct
5 Correct 0 ms 42416 KB Output is correct
6 Correct 0 ms 42416 KB Output is correct
7 Correct 0 ms 42416 KB Output is correct
8 Correct 0 ms 42416 KB Output is correct
9 Correct 0 ms 42416 KB Output is correct
10 Correct 0 ms 42416 KB Output is correct
11 Correct 0 ms 42416 KB Output is correct
12 Correct 0 ms 42416 KB Output is correct
13 Correct 0 ms 42416 KB Output is correct
14 Correct 0 ms 42416 KB Output is correct
15 Correct 0 ms 42416 KB Output is correct
16 Correct 0 ms 42416 KB Output is correct
17 Correct 0 ms 42416 KB Output is correct
18 Correct 0 ms 42416 KB Output is correct
19 Correct 0 ms 42416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 42416 KB Output is correct
2 Correct 8 ms 42416 KB Output is correct
3 Correct 4 ms 42416 KB Output is correct
4 Correct 4 ms 42416 KB Output is correct
5 Correct 8 ms 42416 KB Output is correct
6 Correct 8 ms 42416 KB Output is correct
7 Correct 8 ms 42416 KB Output is correct
8 Correct 0 ms 42416 KB Output is correct
9 Correct 8 ms 42416 KB Output is correct
10 Correct 4 ms 42416 KB Output is correct
11 Correct 8 ms 42416 KB Output is correct
12 Correct 8 ms 42416 KB Output is correct
13 Correct 4 ms 42416 KB Output is correct
14 Correct 4 ms 42416 KB Output is correct
15 Correct 4 ms 42416 KB Output is correct
16 Correct 8 ms 42416 KB Output is correct
17 Correct 4 ms 42416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 568 ms 42416 KB Output is correct
2 Correct 608 ms 42416 KB Output is correct
3 Correct 588 ms 42416 KB Output is correct
4 Correct 592 ms 42416 KB Output is correct
5 Correct 480 ms 42416 KB Output is correct
6 Correct 568 ms 42416 KB Output is correct
7 Correct 612 ms 42416 KB Output is correct
8 Correct 576 ms 42416 KB Output is correct
9 Correct 564 ms 42416 KB Output is correct
10 Correct 560 ms 42416 KB Output is correct
11 Correct 552 ms 42416 KB Output is correct
12 Correct 556 ms 42416 KB Output is correct
13 Correct 504 ms 42416 KB Output is correct
14 Correct 544 ms 42416 KB Output is correct
15 Correct 432 ms 42416 KB Output is correct
16 Correct 552 ms 42416 KB Output is correct
17 Correct 576 ms 42416 KB Output is correct
18 Correct 512 ms 42416 KB Output is correct
19 Correct 576 ms 42416 KB Output is correct
20 Correct 584 ms 42416 KB Output is correct
21 Correct 496 ms 42416 KB Output is correct