#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <deque>
#include <utility>
#include <bitset>
#include <limits.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
typedef double lf;
typedef unsigned int uint;
typedef long double llf;
typedef pair<int, int> pii;
const int SZ = 2222;
int N;
int A[SZ+10][SZ+10];
int Table[SZ+10][SZ+10];
int main() {
scanf("%d", &N);
for(int i = 1; i <= N; i++) for(int j = 1; j <= N; j++) scanf("%d", &A[i][j]), Table[i][j] = (int)1e9;
Table[1][1] = 0;
for(int i = 1; i <= N; i++) for(int j = 1; j <= N; j++) {
if(i+1 <= N) Table[i+1][j] = min(Table[i+1][j], Table[i][j] + max(A[i+1][j] - A[i][j] + 1, 0));
if(j+1 <= N) Table[i][j+1] = min(Table[i][j+1], Table[i][j] + max(A[i][j+1] - A[i][j] + 1, 0));
}
printf("%d\n", Table[N][N]);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
40008 KB |
Output is correct |
2 |
Correct |
0 ms |
40008 KB |
Output is correct |
3 |
Correct |
0 ms |
40008 KB |
Output is correct |
4 |
Correct |
0 ms |
40008 KB |
Output is correct |
5 |
Correct |
0 ms |
40008 KB |
Output is correct |
6 |
Correct |
0 ms |
40008 KB |
Output is correct |
7 |
Correct |
0 ms |
40008 KB |
Output is correct |
8 |
Correct |
0 ms |
40008 KB |
Output is correct |
9 |
Correct |
0 ms |
40008 KB |
Output is correct |
10 |
Correct |
0 ms |
40008 KB |
Output is correct |
11 |
Correct |
0 ms |
40008 KB |
Output is correct |
12 |
Correct |
0 ms |
40008 KB |
Output is correct |
13 |
Correct |
0 ms |
40008 KB |
Output is correct |
14 |
Correct |
0 ms |
40008 KB |
Output is correct |
15 |
Correct |
0 ms |
40008 KB |
Output is correct |
16 |
Correct |
0 ms |
40008 KB |
Output is correct |
17 |
Correct |
0 ms |
40008 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
40008 KB |
Output is correct |
2 |
Correct |
0 ms |
40008 KB |
Output is correct |
3 |
Correct |
0 ms |
40008 KB |
Output is correct |
4 |
Correct |
0 ms |
40008 KB |
Output is correct |
5 |
Correct |
0 ms |
40008 KB |
Output is correct |
6 |
Correct |
0 ms |
40008 KB |
Output is correct |
7 |
Correct |
0 ms |
40008 KB |
Output is correct |
8 |
Correct |
0 ms |
40008 KB |
Output is correct |
9 |
Correct |
0 ms |
40008 KB |
Output is correct |
10 |
Correct |
0 ms |
40008 KB |
Output is correct |
11 |
Correct |
0 ms |
40008 KB |
Output is correct |
12 |
Correct |
0 ms |
40008 KB |
Output is correct |
13 |
Correct |
0 ms |
40008 KB |
Output is correct |
14 |
Correct |
0 ms |
40008 KB |
Output is correct |
15 |
Correct |
0 ms |
40008 KB |
Output is correct |
16 |
Correct |
0 ms |
40008 KB |
Output is correct |
17 |
Correct |
0 ms |
40008 KB |
Output is correct |
18 |
Correct |
0 ms |
40008 KB |
Output is correct |
19 |
Correct |
0 ms |
40008 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
40008 KB |
Output is correct |
2 |
Correct |
4 ms |
40008 KB |
Output is correct |
3 |
Correct |
8 ms |
40008 KB |
Output is correct |
4 |
Correct |
8 ms |
40008 KB |
Output is correct |
5 |
Correct |
8 ms |
40008 KB |
Output is correct |
6 |
Correct |
4 ms |
40008 KB |
Output is correct |
7 |
Correct |
8 ms |
40008 KB |
Output is correct |
8 |
Correct |
0 ms |
40008 KB |
Output is correct |
9 |
Correct |
4 ms |
40008 KB |
Output is correct |
10 |
Correct |
8 ms |
40008 KB |
Output is correct |
11 |
Correct |
4 ms |
40008 KB |
Output is correct |
12 |
Correct |
8 ms |
40008 KB |
Output is correct |
13 |
Correct |
8 ms |
40008 KB |
Output is correct |
14 |
Correct |
4 ms |
40008 KB |
Output is correct |
15 |
Correct |
8 ms |
40008 KB |
Output is correct |
16 |
Correct |
8 ms |
40008 KB |
Output is correct |
17 |
Correct |
8 ms |
40008 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
608 ms |
40008 KB |
Output is correct |
2 |
Correct |
640 ms |
40008 KB |
Output is correct |
3 |
Correct |
620 ms |
40008 KB |
Output is correct |
4 |
Correct |
604 ms |
40008 KB |
Output is correct |
5 |
Correct |
496 ms |
40008 KB |
Output is correct |
6 |
Correct |
552 ms |
40008 KB |
Output is correct |
7 |
Correct |
588 ms |
40008 KB |
Output is correct |
8 |
Correct |
628 ms |
40008 KB |
Output is correct |
9 |
Correct |
604 ms |
40008 KB |
Output is correct |
10 |
Correct |
584 ms |
40008 KB |
Output is correct |
11 |
Correct |
556 ms |
40008 KB |
Output is correct |
12 |
Correct |
572 ms |
40008 KB |
Output is correct |
13 |
Correct |
504 ms |
40008 KB |
Output is correct |
14 |
Correct |
584 ms |
40008 KB |
Output is correct |
15 |
Correct |
456 ms |
40008 KB |
Output is correct |
16 |
Correct |
576 ms |
40008 KB |
Output is correct |
17 |
Correct |
592 ms |
40008 KB |
Output is correct |
18 |
Correct |
536 ms |
40008 KB |
Output is correct |
19 |
Correct |
596 ms |
40008 KB |
Output is correct |
20 |
Correct |
564 ms |
40008 KB |
Output is correct |
21 |
Correct |
492 ms |
40008 KB |
Output is correct |