Submission #7577

#TimeUsernameProblemLanguageResultExecution timeMemory
7577dohyun0324배열 탈출 (GA8_array)C++98
100 / 100
620 ms49916 KiB
#include<stdio.h> int n,a[2500][2500],d[2500][2500]; int mini(int x,int y) { if(x<y) return x; return y; } int f(int x) { if(x>0) return x; return 0; } int main() { int 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++) { for(j=0;j<=n;j++) { if(i==0 || j==0) d[i][j]=2100000000; } } for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { if(i==1 && j==1) continue; d[i][j]=mini(d[i-1][j]+f(a[i][j]-a[i-1][j]+1),d[i][j-1]+f(a[i][j]-a[i][j-1]+1)); } } printf("%d",d[n][n]); 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...