Submission #7936

#TimeUsernameProblemLanguageResultExecution timeMemory
7936cki86201배열 탈출 (GA8_array)C++98
100 / 100
652 ms39764 KiB
#include<stdio.h> #include<algorithm> 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] = 222 * 2222 + 2; for(i=1;i<=n;i++)for(j=1;j<=n;j++){ if(i+j==2)continue; d[i][j] = std::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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...