Submission #7349

#TimeUsernameProblemLanguageResultExecution timeMemory
7349ansol4328배열 탈출 (GA8_array)C++98
100 / 100
636 ms39764 KiB
#include<stdio.h> #define INF 2100000000 int n, m[2225][2225]; int dp[2225][2225]; int min(int a, int b) { if(a<=b) return a; if(a>b) return b; } int p(int a, int b) { if(a-b>0) return 0; if(a-b<=0) return b-a+1; } int main() { int i, j; scanf("%d",&n); for(i=1 ; i<=n ; i++) { for(j=1 ; j<=n ; j++) { scanf("%d",&m[i][j]); dp[i][j]=INF; } } dp[1][1]=0; for(i=2 ; i<=n ; i++) dp[i][1]=dp[i-1][1]+p(m[i-1][1],m[i][1]), dp[1][i]=dp[1][i-1]+p(m[1][i-1],m[1][i]); for(i=2 ; i<=n ; i++) for(j=2 ; j<=n ; j++) dp[i][j]=min(dp[i-1][j]+p(m[i-1][j],m[i][j]),dp[i][j-1]+p(m[i][j-1],m[i][j])); printf("%d",dp[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...