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 a[2223][2223],n,i,j,b[2223][2223];
int am(int a,int b){return a>b?a:b;}
int bm(int a,int b){return a>b?b:a;}
int main()
{
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
scanf("%d",&a[i][j]);
}
}
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
if(i==1)
{
if(j==1)
{
continue;
}
b[1][j]=am(0,a[1][j]-a[1][j-1]+1)+b[1][j-1];
}
else if(j==1)
{
b[i][1]=am(0,a[i][1]-a[i-1][1]+1)+b[i-1][1];
}
else
{
b[i][j]=bm(am(0,a[i][j]-a[i][j-1]+1)+b[i][j-1],am(0,a[i][j]-a[i-1][j]+1)+b[i-1][j]);
}
}
}
printf("%d",b[n][n]);
}
# | 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... |