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>
#include<algorithm>
int a[2225][2225], d[2225][2225];
int main(){
int n,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++)d[i][0] = d[0][i] = 222 * 2222 + 2;
for(i=1;i<=n;i++)for(j=1;j<=n;j++){
if(i+j==2)continue;
d[i][j] = std::min(d[i-1][j] + ((a[i-1][j]>a[i][j]) ? 0 : a[i][j]-a[i-1][j]+1), d[i][j-1] + ((a[i][j-1]>a[i][j]) ? 0 : 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... |