Submission #7729

#TimeUsernameProblemLanguageResultExecution timeMemory
7729ggoh배열 탈출 (GA8_array)C++98
100 / 100
676 ms39696 KiB
#include<cstdio> int a,i,j,x,y,z[2223][2223],D[2223][2223]; int min(int A,int B) { if(A>B)return B; else return A; } main() { scanf("%d",&a); for(i=1;i<=a;i++) { for(j=1;j<=a;j++) { scanf("%d",&z[i][j]); } } for(i=2;i<=a;i++) { if(z[i][1]>=z[i-1][1]) { D[i][1]=D[i-1][1]+z[i][1]-z[i-1][1]+1; } else { D[i][1]=D[i-1][1]; } if(z[1][i]>=z[1][i-1]) { D[1][i]=D[1][i-1]+z[1][i]-z[1][i-1]+1; } else { D[1][i]=D[1][i-1]; } } for(i=2;i<=a;i++) { for(j=2;j<=a;j++) { if(z[i][j]>=z[i][j-1]) { x=z[i][j]-z[i][j-1]+1; } else x=0; if(z[i][j]>=z[i-1][j]) { y=z[i][j]-z[i-1][j]+1; } else y=0; D[i][j]=min(D[i][j-1]+x,D[i-1][j]+y); } } printf("%d",D[a][a]); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...