Submission #7850

#TimeUsernameProblemLanguageResultExecution timeMemory
7850ainu7배열 탈출 (GA8_array)C++98
100 / 100
668 ms43836 KiB
#include <math.h> #include <stdio.h> #include <string.h> #include <vector> #include <string> #include <queue> #include <map> #include <algorithm> #include <cmath> #include <iostream> #include <sstream> #include <set> using namespace std; int a[2323][2323]; int cost[2323][2323]; int from(int b, int c) { return max(0, c-b+1); } int main() { int n; scanf("%d", &n); for (int i=0; i<n; i++) for (int j=0; j<n; j++) scanf("%d", &a[i][j]); for (int i=0; i<n; i++) for (int j=0; j<n; j++) { if (i == 0 && j == 0) { cost[i][j] = 0; continue; } cost[i][j] = 999999999; if (i) cost[i][j] = min(cost[i][j], cost[i-1][j] + from(a[i-1][j], a[i][j])); if (j) cost[i][j] = min(cost[i][j], cost[i][j-1] + from(a[i][j-1], a[i][j])); } printf("%d\n", cost[n-1][n-1]); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...