Submission #7493

#TimeUsernameProblemLanguageResultExecution timeMemory
7493Namnamseo배열 탈출 (GA8_array)C++98
100 / 100
656 ms42416 KiB
#include <cstdio> int map[2300][2300]; int n; int mincost[2300][2300]; int max(int a,int b) {return (a>b)?a:b; } int min(int a,int b) {return (a<b)?a:b; } int main() { scanf("%d",&n); int i,j; for(i=1;i<=n;i++){ for(j=1;j<=n;j++){ scanf("%d",&map[i][j]); if(i==1 && j==1){ mincost[i][j]=0; } else { mincost[i][j]=2147483600; if(j>1) { if(map[i][j-1]<=map[i][j]){ mincost[i][j]=min(mincost[i][j], mincost[i][j-1]+map[i][j]-map[i][j-1]+1); } else { mincost[i][j]=min(mincost[i][j], mincost[i][j-1]); } } if(i>1) { if(map[i-1][j]<=map[i][j]){ mincost[i][j]=min(mincost[i][j], mincost[i-1][j]+map[i][j]-map[i-1][j]+1); } else { mincost[i][j]=min(mincost[i][j], mincost[i-1][j]); } } } } } printf("%d\n",mincost[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...