답안 #7424

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
7424 2014-08-05T06:21:47 Z mrcamel 배열 탈출 (GA8_array) C++
100 / 100
636 ms 39692 KB
#include <cstdio>
using namespace std;

#define in cin
#define out cout

struct RR
{
    int w, cost;
};
RR room[2223][2223];

int main()
{
    int n; scanf("%d", &n);
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            scanf("%d", &room[i][j].w);
            room[i][j].cost = 0;
        }
    }
    for(int i=0; i<=n; i++)
    {
        room[0][i].w = 300;
        room[i][0].w = 300;
    }

    //
    for(int i=2; i<=n; i++)
    {
        if(room[1][i-1].w <= room[1][i].w)
            room[1][i].cost = room[1][i].w - room[1][i-1].w + 1;
        if(room[i-1][1].w <= room[i][1].w)
            room[i][1].cost = room[i][1].w - room[i-1][1].w + 1;

        room[1][i].cost += room[1][i-1].cost;
        room[i][1].cost += room[i-1][1].cost;
    }

    for(int i=2; i<=n; i++)
    {
        for(int j=2; j<=n; j++)
        {
            RR &r0 = room[i][j];
            RR &r1 = room[i-1][j];
            RR &r2 = room[i][j-1];

            int r1c = 0;
            int r2c = 0;

            if(r0.w >= r1.w) r1c = r0.w - r1.w + 1;
            r1c += r1.cost;
            if(r0.w >= r2.w) r2c = r0.w - r2.w + 1;
            r2c += r2.cost;

            if(r1c < r2c) r0.cost = r1c;
            else r0.cost = r2c;
        }
    }

    printf("%d", room[n][n].cost);

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 39692 KB Output is correct
2 Correct 0 ms 39692 KB Output is correct
3 Correct 0 ms 39692 KB Output is correct
4 Correct 0 ms 39692 KB Output is correct
5 Correct 0 ms 39692 KB Output is correct
6 Correct 0 ms 39692 KB Output is correct
7 Correct 0 ms 39692 KB Output is correct
8 Correct 0 ms 39692 KB Output is correct
9 Correct 0 ms 39692 KB Output is correct
10 Correct 0 ms 39692 KB Output is correct
11 Correct 0 ms 39692 KB Output is correct
12 Correct 0 ms 39692 KB Output is correct
13 Correct 0 ms 39692 KB Output is correct
14 Correct 0 ms 39692 KB Output is correct
15 Correct 0 ms 39692 KB Output is correct
16 Correct 0 ms 39692 KB Output is correct
17 Correct 0 ms 39692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 39692 KB Output is correct
2 Correct 0 ms 39692 KB Output is correct
3 Correct 0 ms 39692 KB Output is correct
4 Correct 0 ms 39692 KB Output is correct
5 Correct 0 ms 39692 KB Output is correct
6 Correct 0 ms 39692 KB Output is correct
7 Correct 0 ms 39692 KB Output is correct
8 Correct 0 ms 39692 KB Output is correct
9 Correct 0 ms 39692 KB Output is correct
10 Correct 0 ms 39692 KB Output is correct
11 Correct 0 ms 39692 KB Output is correct
12 Correct 0 ms 39692 KB Output is correct
13 Correct 0 ms 39692 KB Output is correct
14 Correct 0 ms 39692 KB Output is correct
15 Correct 0 ms 39692 KB Output is correct
16 Correct 0 ms 39692 KB Output is correct
17 Correct 0 ms 39692 KB Output is correct
18 Correct 0 ms 39692 KB Output is correct
19 Correct 0 ms 39692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 39692 KB Output is correct
2 Correct 8 ms 39692 KB Output is correct
3 Correct 8 ms 39692 KB Output is correct
4 Correct 8 ms 39692 KB Output is correct
5 Correct 8 ms 39692 KB Output is correct
6 Correct 4 ms 39692 KB Output is correct
7 Correct 8 ms 39692 KB Output is correct
8 Correct 8 ms 39692 KB Output is correct
9 Correct 0 ms 39692 KB Output is correct
10 Correct 8 ms 39692 KB Output is correct
11 Correct 4 ms 39692 KB Output is correct
12 Correct 0 ms 39692 KB Output is correct
13 Correct 4 ms 39692 KB Output is correct
14 Correct 4 ms 39692 KB Output is correct
15 Correct 8 ms 39692 KB Output is correct
16 Correct 8 ms 39692 KB Output is correct
17 Correct 4 ms 39692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 616 ms 39692 KB Output is correct
2 Correct 612 ms 39692 KB Output is correct
3 Correct 600 ms 39692 KB Output is correct
4 Correct 616 ms 39692 KB Output is correct
5 Correct 524 ms 39692 KB Output is correct
6 Correct 572 ms 39692 KB Output is correct
7 Correct 624 ms 39692 KB Output is correct
8 Correct 636 ms 39692 KB Output is correct
9 Correct 620 ms 39692 KB Output is correct
10 Correct 560 ms 39692 KB Output is correct
11 Correct 552 ms 39692 KB Output is correct
12 Correct 548 ms 39692 KB Output is correct
13 Correct 496 ms 39692 KB Output is correct
14 Correct 552 ms 39692 KB Output is correct
15 Correct 468 ms 39692 KB Output is correct
16 Correct 556 ms 39692 KB Output is correct
17 Correct 568 ms 39692 KB Output is correct
18 Correct 496 ms 39692 KB Output is correct
19 Correct 568 ms 39692 KB Output is correct
20 Correct 564 ms 39692 KB Output is correct
21 Correct 508 ms 39692 KB Output is correct