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<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;
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;
}
# | 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... |