이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
int n, A[224][224] = { 0 }, cost[224][224] = { 0 };
int main(){
scanf("%d", &n);
for (int i = 1; i <= n; ++i){
for (int j = 1; j <= n; ++j){
scanf("%d", &A[i][j]);
}
}
for (int i = n; i; --i){
for (int j = n; j; --j){
int rcost = cost[i][j + 1] + (A[i][j] > A[i][j + 1] ? 0 : A[i][j + 1] - A[i][j] + 1);
int dcost = cost[i + 1][j] + (A[i][j] > A[i + 1][j] ? 0 : A[i + 1][j] - A[i][j] + 1);
if (i == n && j == n) cost[n][n] = 0;
else if (i == n) cost[n][j] = rcost;
else if (j == n) cost[i][n] = dcost;
else cost[i][j] = (rcost > dcost ? dcost : rcost);
}
}
printf("%d\n", cost[1][1]);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |