This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
int map[2222][2222];
int dp[2222][2222];
int v(int s, int e) {
return (s > e) ? 0 : (e - s + 1);
}
int main() {
int n, i, j;
scanf("%d", &n);
// 미친;
// 하... 이런 선언 실수를 하다니. 한심하다... 에휴
for (i=0; i<n; ++i) {
for (j=0; j<n; ++j) {
scanf("%d", &map[i][j]);
}
}
for (j=1; j<n; ++j) {
dp[0][j] = dp[0][j - 1] + v(map[0][j - 1], map[0][j]);
}
for (i=1; i<n; ++i) {
for (j=0; j<n; ++j) {
int temp = dp[i - 1][j] + v(map[i - 1][j], map[i][j]);
if (j != 0) {
int temp2 = dp[i][j - 1] + v(map[i][j - 1], map[i][j]);
if (temp > temp2) {
temp = temp2;
}
}
dp[i][j] = temp;
}
}
printf("%d\n", dp[n - 1][n - 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... |