#include <stdio.h>
#include <algorithm>
int N; long long A[2222][2222],D[2222][2222];
int main()
{
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) D[i][j] = 0;
else D[i][j] = 1000000000000000ll;
if (i != 0){
int a = (A[i-1][j] > A[i][j]) ? 0 : A[i][j] - A[i-1][j] + 1;
if (D[i][j] > D[i-1][j] + a)
D[i][j] = D[i-1][j] + a;
}
if (j != 0){
int a = (A[i][j-1] > A[i][j]) ? 0 : A[i][j] - A[i][j-1] + 1;
if (D[i][j] > D[i][j-1] + a)
D[i][j] = D[i][j-1] + a;
}
}
printf ("%d\n",D[N-1][N-1]);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Memory limit exceeded |
0 ms |
65536 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Memory limit exceeded |
0 ms |
65536 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Memory limit exceeded |
0 ms |
65536 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Memory limit exceeded |
0 ms |
65536 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |