Submission #7604

#TimeUsernameProblemLanguageResultExecution timeMemory
7604gs13031배열 탈출 (GA8_array)C++98
100 / 100
676 ms39936 KiB
#include<stdio.h> int n, a[2230][2230], dp[2230][2230]; int main() { int i, j, x, y; scanf("%d", &n); for(i=1; i<=n; ++i) { for(j=1; j<=n; ++j) { scanf("%d", &a[i][j]); } } for(i=1; i<=n; ++i) { for(j=1; j<=n; ++j) { if(i==1 && j==1) continue; x=i>1?dp[i-1][j]:1234567890; y=j>1?dp[i][j-1]:1234567890; if(a[i][j]>=a[i-1][j]) x+=a[i][j]-a[i-1][j]+1; if(a[i][j]>=a[i][j-1]) y+=a[i][j]-a[i][j-1]+1; if(x<y) dp[i][j]=x; else dp[i][j]=y; } } printf("%d", dp[n][n]); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...