Submission #7603

#TimeUsernameProblemLanguageResultExecution timeMemory
7603gs13031배열 탈출 (GA8_array)C++98
6 / 100
680 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=dp[i-1][j];y=dp[i][j-1]; 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...