답안 #7596

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
7596 2014-08-12T06:56:02 Z jihoon 배열 탈출 (GA8_array) C++
100 / 100
664 ms 39660 KB
#include<cstdio>
#include<algorithm>
#define inf 2100000000
using namespace std;

int bae[2222][2222];
int dp[2222][2222];
int n;

int main(){
    int i,j;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            dp[i][j]=inf;
            scanf("%d",&bae[i][j]);
        }
    }
    dp[0][0]=0;
    for(i=0;i<n-1;i++){
        for(j=0;j<n-1;j++){
            if(bae[i][j]>bae[i][j+1]){
                dp[i][j+1]=min(dp[i][j+1],dp[i][j]);
            }else{
                dp[i][j+1]=min(dp[i][j+1],bae[i][j+1]-bae[i][j]+1+dp[i][j]);
            }
        }
        for(j=0;j<n;j++){
            if(bae[i][j]>bae[i+1][j]){
                dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
            }else{
                dp[i+1][j]=min(dp[i+1][j],bae[i+1][j]-bae[i][j]+1+dp[i][j]);
            }
        }
    }
    for(j=0;j<n-1;j++){
        if(bae[i][j]>bae[i][j+1]){
            dp[i][j+1]=min(dp[i][j+1],dp[i][j]);
        }else{
            dp[i][j+1]=min(dp[i][j+1],bae[i][j+1]-bae[i][j]+1+dp[i][j]);
        }
    }
    printf("%d",dp[n-1][n-1]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 39660 KB Output is correct
2 Correct 0 ms 39660 KB Output is correct
3 Correct 0 ms 39660 KB Output is correct
4 Correct 0 ms 39660 KB Output is correct
5 Correct 0 ms 39660 KB Output is correct
6 Correct 0 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 0 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 0 ms 39660 KB Output is correct
14 Correct 0 ms 39660 KB Output is correct
15 Correct 0 ms 39660 KB Output is correct
16 Correct 0 ms 39660 KB Output is correct
17 Correct 0 ms 39660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 39660 KB Output is correct
2 Correct 0 ms 39660 KB Output is correct
3 Correct 0 ms 39660 KB Output is correct
4 Correct 0 ms 39660 KB Output is correct
5 Correct 0 ms 39660 KB Output is correct
6 Correct 0 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 0 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 0 ms 39660 KB Output is correct
14 Correct 0 ms 39660 KB Output is correct
15 Correct 0 ms 39660 KB Output is correct
16 Correct 0 ms 39660 KB Output is correct
17 Correct 0 ms 39660 KB Output is correct
18 Correct 0 ms 39660 KB Output is correct
19 Correct 0 ms 39660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 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 8 ms 39660 KB Output is correct
5 Correct 8 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 0 ms 39660 KB Output is correct
10 Correct 8 ms 39660 KB Output is correct
11 Correct 8 ms 39660 KB Output is correct
12 Correct 8 ms 39660 KB Output is correct
13 Correct 4 ms 39660 KB Output is correct
14 Correct 8 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 632 ms 39660 KB Output is correct
2 Correct 644 ms 39660 KB Output is correct
3 Correct 616 ms 39660 KB Output is correct
4 Correct 644 ms 39660 KB Output is correct
5 Correct 540 ms 39660 KB Output is correct
6 Correct 592 ms 39660 KB Output is correct
7 Correct 656 ms 39660 KB Output is correct
8 Correct 660 ms 39660 KB Output is correct
9 Correct 664 ms 39660 KB Output is correct
10 Correct 564 ms 39660 KB Output is correct
11 Correct 524 ms 39660 KB Output is correct
12 Correct 528 ms 39660 KB Output is correct
13 Correct 492 ms 39660 KB Output is correct
14 Correct 532 ms 39660 KB Output is correct
15 Correct 464 ms 39660 KB Output is correct
16 Correct 536 ms 39660 KB Output is correct
17 Correct 568 ms 39660 KB Output is correct
18 Correct 480 ms 39660 KB Output is correct
19 Correct 568 ms 39660 KB Output is correct
20 Correct 572 ms 39660 KB Output is correct
21 Correct 532 ms 39660 KB Output is correct