#include<stdio.h>
int n,a[2500][2500],d[2500][2500];
int mini(int x,int y)
{
if(x<y) return x;
return y;
}
int f(int x)
{
if(x>0) return x;
return 0;
}
int main()
{
int i,j;
freopen("input.txt","r",stdin);
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
scanf("%d",&a[i][j]);
}
}
for(i=0;i<=n;i++)
{
for(j=0;j<=n;j++)
{
if(i==0 || j==0) d[i][j]=2100000000;
}
}
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
if(i==1 && j==1) continue;
d[i][j]=mini(d[i-1][j]+f(a[i][j]-a[i-1][j]+1),d[i][j-1]+f(a[i][j]-a[i][j-1]+1));
}
}
printf("%d",d[n][n]);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
49908 KB |
open (syscall #2) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
49908 KB |
open (syscall #2) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
49908 KB |
open (syscall #2) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
49908 KB |
open (syscall #2) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |