Submission #7890

#TimeUsernameProblemLanguageResultExecution timeMemory
7890Qwaz배열 탈출 (GA8_array)C++14
100 / 100
612 ms42416 KiB
#include <cstdio> #include <algorithm> using namespace std; const int MAX = 2300, INF = 1234567890; int n, map[MAX][MAX]; void input(){ scanf("%d", &n); int i, j; for(i = 1; i<=n; i++){ for(j = 1; j<=n; j++){ scanf("%d", &map[i][j]); } } } int cost[MAX][MAX]; void solve(){ int i, j; for(i = 1; i<=n; i++){ for(j = 1; j<=n; j++){ if(i == 1 && j == 1) continue; cost[i][j] = INF; if(i > 1) cost[i][j] = min(cost[i][j], cost[i-1][j]+max(0, map[i][j]-map[i-1][j]+1)); if(j > 1) cost[i][j] = min(cost[i][j], cost[i][j-1]+max(0, map[i][j]-map[i][j-1]+1)); } } printf("%d\n", cost[n][n]); } int main(){ input(); solve(); 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...