#include <stdio.h>
#include <algorithm>
using namespace std;
int a[2223][2223],D[2223][2223];
int main(){
int i,j,n;
scanf("%d",&n);
for(i=1;i<=n;++i)for(j=1;j<=n;++j)scanf("%d",a[i]+j);
for(i=2;i<=n;++i)a[i][0]=a[0][i]=-1e8;
for(i=1;i<=n;++i)for(j=1;j<=n;++j)D[i][j]=min(D[i-1][j]+max(a[i][j]-a[i-1][j]+1,0),D[i][j-1]+max(a[i][j]-a[i][j-1]+1,0));
printf("%d",D[n][n]-D[1][1]);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
39688 KB |
Output is correct |
2 |
Correct |
0 ms |
39688 KB |
Output is correct |
3 |
Correct |
0 ms |
39688 KB |
Output is correct |
4 |
Correct |
0 ms |
39688 KB |
Output is correct |
5 |
Correct |
0 ms |
39688 KB |
Output is correct |
6 |
Correct |
0 ms |
39688 KB |
Output is correct |
7 |
Correct |
0 ms |
39688 KB |
Output is correct |
8 |
Correct |
0 ms |
39688 KB |
Output is correct |
9 |
Correct |
0 ms |
39688 KB |
Output is correct |
10 |
Correct |
0 ms |
39688 KB |
Output is correct |
11 |
Correct |
0 ms |
39688 KB |
Output is correct |
12 |
Correct |
0 ms |
39688 KB |
Output is correct |
13 |
Correct |
0 ms |
39688 KB |
Output is correct |
14 |
Correct |
0 ms |
39688 KB |
Output is correct |
15 |
Correct |
0 ms |
39688 KB |
Output is correct |
16 |
Correct |
0 ms |
39688 KB |
Output is correct |
17 |
Correct |
0 ms |
39688 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
39688 KB |
Output is correct |
2 |
Correct |
0 ms |
39688 KB |
Output is correct |
3 |
Correct |
0 ms |
39688 KB |
Output is correct |
4 |
Correct |
0 ms |
39688 KB |
Output is correct |
5 |
Correct |
0 ms |
39688 KB |
Output is correct |
6 |
Correct |
0 ms |
39688 KB |
Output is correct |
7 |
Correct |
0 ms |
39688 KB |
Output is correct |
8 |
Correct |
0 ms |
39688 KB |
Output is correct |
9 |
Correct |
0 ms |
39688 KB |
Output is correct |
10 |
Correct |
0 ms |
39688 KB |
Output is correct |
11 |
Correct |
0 ms |
39688 KB |
Output is correct |
12 |
Correct |
0 ms |
39688 KB |
Output is correct |
13 |
Correct |
0 ms |
39688 KB |
Output is correct |
14 |
Correct |
0 ms |
39688 KB |
Output is correct |
15 |
Correct |
0 ms |
39688 KB |
Output is correct |
16 |
Correct |
0 ms |
39688 KB |
Output is correct |
17 |
Correct |
0 ms |
39688 KB |
Output is correct |
18 |
Correct |
0 ms |
39688 KB |
Output is correct |
19 |
Correct |
0 ms |
39688 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
39688 KB |
Output is correct |
2 |
Correct |
5 ms |
39688 KB |
Output is correct |
3 |
Correct |
5 ms |
39688 KB |
Output is correct |
4 |
Correct |
4 ms |
39688 KB |
Output is correct |
5 |
Correct |
8 ms |
39688 KB |
Output is correct |
6 |
Correct |
5 ms |
39688 KB |
Output is correct |
7 |
Correct |
10 ms |
39688 KB |
Output is correct |
8 |
Correct |
8 ms |
39688 KB |
Output is correct |
9 |
Correct |
7 ms |
39688 KB |
Output is correct |
10 |
Correct |
7 ms |
39688 KB |
Output is correct |
11 |
Correct |
0 ms |
39688 KB |
Output is correct |
12 |
Correct |
0 ms |
39688 KB |
Output is correct |
13 |
Correct |
9 ms |
39688 KB |
Output is correct |
14 |
Correct |
7 ms |
39688 KB |
Output is correct |
15 |
Correct |
8 ms |
39688 KB |
Output is correct |
16 |
Correct |
4 ms |
39688 KB |
Output is correct |
17 |
Correct |
3 ms |
39688 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
648 ms |
39688 KB |
Output is correct |
2 |
Correct |
588 ms |
39688 KB |
Output is correct |
3 |
Correct |
624 ms |
39688 KB |
Output is correct |
4 |
Correct |
685 ms |
39688 KB |
Output is correct |
5 |
Correct |
517 ms |
39688 KB |
Output is correct |
6 |
Correct |
598 ms |
39688 KB |
Output is correct |
7 |
Correct |
601 ms |
39688 KB |
Output is correct |
8 |
Correct |
630 ms |
39688 KB |
Output is correct |
9 |
Correct |
691 ms |
39688 KB |
Output is correct |
10 |
Correct |
597 ms |
39688 KB |
Output is correct |
11 |
Correct |
609 ms |
39688 KB |
Output is correct |
12 |
Correct |
571 ms |
39688 KB |
Output is correct |
13 |
Correct |
540 ms |
39688 KB |
Output is correct |
14 |
Correct |
593 ms |
39688 KB |
Output is correct |
15 |
Correct |
495 ms |
39688 KB |
Output is correct |
16 |
Correct |
682 ms |
39688 KB |
Output is correct |
17 |
Correct |
657 ms |
39688 KB |
Output is correct |
18 |
Correct |
638 ms |
39688 KB |
Output is correct |
19 |
Correct |
624 ms |
39688 KB |
Output is correct |
20 |
Correct |
598 ms |
39688 KB |
Output is correct |
21 |
Correct |
557 ms |
39688 KB |
Output is correct |