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>
#define MAXN 2332
#define INF 2100000000
int N;
int Number[MAXN][MAXN];
int Dy[MAXN][MAXN];
int MIN(int x, int y) {
if(x>y) return y;
else return x;
}
int Money(int now, int next) {
if(now>next) return 0;
return next-now+1;
}
int main() {
scanf("%d", &N);
for(int i=0; i<=N; i++) Dy[0][i] = Dy[i][0] = INF;
for(int i=1; i<=N; i++) {
for(int j=1; j<=N; j++) {
scanf("%d", &Number[i][j]);
if(i==1 && j==1) continue;
Dy[i][j] = MIN(Dy[i-1][j] + Money(Number[i-1][j], Number[i][j])
, Dy[i][j-1] + Money(Number[i][j-1], Number[i][j]));
}
}
printf("%d", Dy[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... |