Submission #7500

#TimeUsernameProblemLanguageResultExecution timeMemory
7500baneling100배열 탈출 (GA8_array)C++98
100 / 100
652 ms39696 KiB
#include <stdio.h> int N, A[2223][2223], D[2223][2223]; void input(void) { int i, j; scanf("%d",&N); for(i=1 ; i<=N ; i++) for(j=1 ; j<=N ; j++) scanf("%d",&A[i][j]); } int Dist(int X, int Y) { if(X>Y) return 0; return Y-X+1; } int MIN(int X, int Y) { if(X<Y) return X; return Y; } void process(void) { int i, j; D[1][1]=0; for(i=2 ; i<=N ; i++) { D[1][i]=D[1][i-1]+Dist(A[1][i-1],A[1][i]); D[i][1]=D[i-1][1]+Dist(A[i-1][1],A[i][1]); } for(i=2 ; i<=N ; i++) for(j=2 ; j<=N ; j++) D[i][j]=MIN(D[i][j-1]+Dist(A[i][j-1],A[i][j]),D[i-1][j]+Dist(A[i-1][j],A[i][j])); } void output(void) { printf("%d",D[N][N]); } int main(void) { input(); process(); output(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...