Submission #7342

#TimeUsernameProblemLanguageResultExecution timeMemory
7342myungwoo배열 탈출 (GA8_array)C++98
100 / 100
660 ms39728 KiB
#include <stdio.h> #define MAXN 2224 int N,A[MAXN][MAXN],D[MAXN][MAXN]; int main() { int i,j,k,s; scanf("%d",&N); for (i=1;i<=N;i++) for (j=1;j<=N;j++) scanf("%d",A[i]+j), D[i][j] = 2e9; D[1][1] = 0; for (i=1;i<=N;i++) for (j=1;j<=N;j++){ if (i < N){ int v = A[i][j] <= A[i+1][j] ? A[i+1][j]-A[i][j]+1 : 0; if (D[i+1][j] > D[i][j]+v) D[i+1][j] = D[i][j]+v; } if (j < N){ int v = A[i][j] <= A[i][j+1] ? A[i][j+1]-A[i][j]+1 : 0; if (D[i][j+1] > D[i][j]+v) D[i][j+1] = D[i][j]+v; } } printf("%d\n",D[N][N]); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...