답안 #7888

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
7888 2014-08-23T02:51:52 Z xhae 배열 탈출 (GA8_array) C++14
100 / 100
692 ms 39816 KB
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int arr[2222][2222], n;
int dp[2222][2222];

int getAns(int y, int x)
{
	int &ret = dp[y][x];
    if(ret != -1) return ret;
    
    if(y == n - 1 and x == n - 1) ret = 0;
    else
    {
    	ret = (1 << 30);
        if(y < n - 1) ret = min(ret, getAns(y + 1, x) + max(0, arr[y + 1][x] + 1 - arr[y][x]));
        if(x < n - 1) ret = min(ret, getAns(y, x + 1) + max(0, arr[y][x + 1] + 1 - arr[y][x]));
    }
    
    return ret;
}   

int main(void)
{
	scanf("%d", &n);
    for(int i = 0; i < n; i++)
    	for(int j = 0; j < n; j++)
        	scanf("%d", arr[i] + j);
    
    memset(dp, -1, sizeof(dp));
    printf("%d\n", getAns(0, 0));
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 39660 KB Output is correct
2 Correct 4 ms 39660 KB Output is correct
3 Correct 4 ms 39660 KB Output is correct
4 Correct 0 ms 39660 KB Output is correct
5 Correct 8 ms 39660 KB Output is correct
6 Correct 8 ms 39660 KB Output is correct
7 Correct 0 ms 39660 KB Output is correct
8 Correct 0 ms 39660 KB Output is correct
9 Correct 0 ms 39660 KB Output is correct
10 Correct 12 ms 39660 KB Output is correct
11 Correct 0 ms 39660 KB Output is correct
12 Correct 0 ms 39660 KB Output is correct
13 Correct 4 ms 39660 KB Output is correct
14 Correct 4 ms 39660 KB Output is correct
15 Correct 4 ms 39660 KB Output is correct
16 Correct 8 ms 39660 KB Output is correct
17 Correct 4 ms 39660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 39660 KB Output is correct
2 Correct 8 ms 39660 KB Output is correct
3 Correct 8 ms 39660 KB Output is correct
4 Correct 4 ms 39660 KB Output is correct
5 Correct 4 ms 39660 KB Output is correct
6 Correct 4 ms 39660 KB Output is correct
7 Correct 4 ms 39660 KB Output is correct
8 Correct 4 ms 39660 KB Output is correct
9 Correct 4 ms 39660 KB Output is correct
10 Correct 12 ms 39660 KB Output is correct
11 Correct 4 ms 39660 KB Output is correct
12 Correct 0 ms 39660 KB Output is correct
13 Correct 8 ms 39660 KB Output is correct
14 Correct 4 ms 39660 KB Output is correct
15 Correct 0 ms 39660 KB Output is correct
16 Correct 8 ms 39660 KB Output is correct
17 Correct 4 ms 39660 KB Output is correct
18 Correct 8 ms 39660 KB Output is correct
19 Correct 4 ms 39660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 39660 KB Output is correct
2 Correct 0 ms 39660 KB Output is correct
3 Correct 8 ms 39660 KB Output is correct
4 Correct 20 ms 39660 KB Output is correct
5 Correct 4 ms 39660 KB Output is correct
6 Correct 8 ms 39660 KB Output is correct
7 Correct 12 ms 39660 KB Output is correct
8 Correct 4 ms 39660 KB Output is correct
9 Correct 4 ms 39660 KB Output is correct
10 Correct 12 ms 39660 KB Output is correct
11 Correct 12 ms 39660 KB Output is correct
12 Correct 12 ms 39660 KB Output is correct
13 Correct 12 ms 39660 KB Output is correct
14 Correct 4 ms 39660 KB Output is correct
15 Correct 12 ms 39660 KB Output is correct
16 Correct 4 ms 39660 KB Output is correct
17 Correct 8 ms 39660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 656 ms 39812 KB Output is correct
2 Correct 676 ms 39812 KB Output is correct
3 Correct 664 ms 39808 KB Output is correct
4 Correct 672 ms 39812 KB Output is correct
5 Correct 584 ms 39788 KB Output is correct
6 Correct 636 ms 39804 KB Output is correct
7 Correct 692 ms 39816 KB Output is correct
8 Correct 680 ms 39816 KB Output is correct
9 Correct 668 ms 39808 KB Output is correct
10 Correct 632 ms 39816 KB Output is correct
11 Correct 636 ms 39812 KB Output is correct
12 Correct 616 ms 39808 KB Output is correct
13 Correct 572 ms 39796 KB Output is correct
14 Correct 636 ms 39812 KB Output is correct
15 Correct 516 ms 39788 KB Output is correct
16 Correct 668 ms 39812 KB Output is correct
17 Correct 644 ms 39812 KB Output is correct
18 Correct 588 ms 39804 KB Output is correct
19 Correct 632 ms 39812 KB Output is correct
20 Correct 644 ms 39816 KB Output is correct
21 Correct 616 ms 39804 KB Output is correct