답안 #7518

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
7518 2014-08-10T10:00:26 Z jalmal 배열 탈출 (GA8_array) C++
100 / 100
828 ms 39936 KB
#include <stdio.h>

int N, arr[2230][2230], tab[2230][2230];

void upd(int x, int y)
{
    int m = 2147483647;
    if(x > 1)
    {
        if(arr[y][x] < arr[y][x-1])
        {
            if(tab[y][x-1] < m) m = tab[y][x-1];
        }
        else
        {
            if(tab[y][x-1] + arr[y][x] - arr[y][x-1] + 1 < m) m = tab[y][x-1] + arr[y][x] - arr[y][x-1] + 1;
        }
    }
    if(y > 1)
    {
        if(arr[y][x] < arr[y-1][x])
        {
            if(tab[y-1][x] < m) m = tab[y-1][x];
        }
        else
        {
            if(tab[y-1][x] + arr[y][x] - arr[y-1][x] + 1 < m) m = tab[y-1][x] + arr[y][x] - arr[y-1][x] + 1;
        }
    }
    tab[y][x] = m;
}

int main()
{
    //freopen("input.txt", "r",  stdin);
    int i, j;

    scanf("%d", &N);
    for(i = 1; i <= N; i ++) for(j = 1; j <= N; j ++) scanf("%d", &arr[i][j]);

    for(i = 2; i <= N; i ++)
    {
        int x, y;
        for(x = 1, y = i; x <= i; x ++, y --)
        {
            upd(x, y);
        }
    }

    for(i = 2; i <= N; i ++)
    {
        int x, y;
        for(x = i, y = N; x <= N; x ++, y --)
        {
            upd(x, y);
        }
    }

    printf("%d", tab[N][N]);

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 39936 KB Output is correct
2 Correct 0 ms 39936 KB Output is correct
3 Correct 0 ms 39936 KB Output is correct
4 Correct 0 ms 39936 KB Output is correct
5 Correct 0 ms 39936 KB Output is correct
6 Correct 0 ms 39936 KB Output is correct
7 Correct 0 ms 39936 KB Output is correct
8 Correct 0 ms 39936 KB Output is correct
9 Correct 0 ms 39936 KB Output is correct
10 Correct 0 ms 39936 KB Output is correct
11 Correct 0 ms 39936 KB Output is correct
12 Correct 0 ms 39936 KB Output is correct
13 Correct 0 ms 39936 KB Output is correct
14 Correct 0 ms 39936 KB Output is correct
15 Correct 0 ms 39936 KB Output is correct
16 Correct 0 ms 39936 KB Output is correct
17 Correct 0 ms 39936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 39936 KB Output is correct
2 Correct 0 ms 39936 KB Output is correct
3 Correct 0 ms 39936 KB Output is correct
4 Correct 0 ms 39936 KB Output is correct
5 Correct 0 ms 39936 KB Output is correct
6 Correct 0 ms 39936 KB Output is correct
7 Correct 0 ms 39936 KB Output is correct
8 Correct 0 ms 39936 KB Output is correct
9 Correct 0 ms 39936 KB Output is correct
10 Correct 0 ms 39936 KB Output is correct
11 Correct 0 ms 39936 KB Output is correct
12 Correct 0 ms 39936 KB Output is correct
13 Correct 0 ms 39936 KB Output is correct
14 Correct 0 ms 39936 KB Output is correct
15 Correct 0 ms 39936 KB Output is correct
16 Correct 0 ms 39936 KB Output is correct
17 Correct 0 ms 39936 KB Output is correct
18 Correct 0 ms 39936 KB Output is correct
19 Correct 0 ms 39936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 39936 KB Output is correct
2 Correct 4 ms 39936 KB Output is correct
3 Correct 4 ms 39936 KB Output is correct
4 Correct 4 ms 39936 KB Output is correct
5 Correct 8 ms 39936 KB Output is correct
6 Correct 4 ms 39936 KB Output is correct
7 Correct 8 ms 39936 KB Output is correct
8 Correct 4 ms 39936 KB Output is correct
9 Correct 4 ms 39936 KB Output is correct
10 Correct 8 ms 39936 KB Output is correct
11 Correct 0 ms 39936 KB Output is correct
12 Correct 0 ms 39936 KB Output is correct
13 Correct 4 ms 39936 KB Output is correct
14 Correct 8 ms 39936 KB Output is correct
15 Correct 4 ms 39936 KB Output is correct
16 Correct 0 ms 39936 KB Output is correct
17 Correct 4 ms 39936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 792 ms 39936 KB Output is correct
2 Correct 784 ms 39936 KB Output is correct
3 Correct 800 ms 39936 KB Output is correct
4 Correct 776 ms 39936 KB Output is correct
5 Correct 636 ms 39936 KB Output is correct
6 Correct 704 ms 39936 KB Output is correct
7 Correct 788 ms 39936 KB Output is correct
8 Correct 828 ms 39936 KB Output is correct
9 Correct 796 ms 39936 KB Output is correct
10 Correct 728 ms 39936 KB Output is correct
11 Correct 700 ms 39936 KB Output is correct
12 Correct 696 ms 39936 KB Output is correct
13 Correct 652 ms 39936 KB Output is correct
14 Correct 708 ms 39936 KB Output is correct
15 Correct 572 ms 39936 KB Output is correct
16 Correct 760 ms 39936 KB Output is correct
17 Correct 708 ms 39936 KB Output is correct
18 Correct 684 ms 39936 KB Output is correct
19 Correct 732 ms 39936 KB Output is correct
20 Correct 696 ms 39936 KB Output is correct
21 Correct 652 ms 39936 KB Output is correct