# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
7934 | 2014-08-26T10:09:43 Z | cki86201 | 배열 탈출 (GA8_array) | C++ | 0 ms | 0 KB |
#include<stdio.h> int a[2225][2225], d[2225][2225]; int main(){ int n,i,j; scanf("%d",&n); for(i=1;i<=n;i++)for(j=1;j<=n;j++)scanf("%d",a[i]+j); for(i=0;i<=n;i++)d[i][0] = d[0][i] = 22222; for(i=1;i<=n;i++)for(j=1;j<=n;j++){ if(i+j==2)continue; d[i][j] = min(d[i-1][j] + ((a[i-1][j]>a[i][j]) ? 0 : a[i][j]-a[i-1][j]+1), d[i][j-1] + ((a[i][j-1]>a[i][j]) ? 0 : a[i][j]-a[i][j-1]+1)); } printf("%d",d[n][n]); return 0; }