# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
378139 |
2021-03-16T05:01:31 Z |
dia312 |
배열 탈출 (GA8_array) |
Python 3 |
|
1289 ms |
65540 KB |
import sys
input=sys.stdin.readline
INF = int(1e9)
n = int(input())
maps = [[INF]*(n+1)]
#배열 입력
for i in range(n):
maps.append([INF]+list(map(int,input().split())))
#비용 초기화
cost = [[0 for _ in range(n+1)] for _ in range(n+1)]
def cal(a,b):
if a>b:
return 0
else:
return b-a+1
#디피
def dp():
for i in range(1,n+1):
for j in range(1,n+1):
if j-1==0 and i-1==0:
continue
elif j-1==0:
cost[i][j]+=cal(maps[i-1][j],maps[i][j]) + cost[i-1][j]
elif i-1==0:
cost[i][j]+=cal(maps[i][j-1],maps[i][j]) + cost[i][j-1]
else:
cost[i][j]+=min(cal(maps[i][j-1],maps[i][j]) + cost[i][j-1],cal(maps[i-1][j],maps[i][j]) + cost[i-1][j])
print(cost[n][n])
dp()
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
2924 KB |
Output is correct |
2 |
Correct |
18 ms |
2924 KB |
Output is correct |
3 |
Correct |
15 ms |
2924 KB |
Output is correct |
4 |
Correct |
18 ms |
2924 KB |
Output is correct |
5 |
Correct |
17 ms |
2924 KB |
Output is correct |
6 |
Correct |
17 ms |
2924 KB |
Output is correct |
7 |
Correct |
17 ms |
3052 KB |
Output is correct |
8 |
Correct |
16 ms |
2924 KB |
Output is correct |
9 |
Correct |
17 ms |
2924 KB |
Output is correct |
10 |
Correct |
17 ms |
2924 KB |
Output is correct |
11 |
Correct |
16 ms |
2924 KB |
Output is correct |
12 |
Correct |
18 ms |
2924 KB |
Output is correct |
13 |
Correct |
17 ms |
2924 KB |
Output is correct |
14 |
Correct |
22 ms |
2924 KB |
Output is correct |
15 |
Correct |
18 ms |
2924 KB |
Output is correct |
16 |
Correct |
17 ms |
2924 KB |
Output is correct |
17 |
Correct |
16 ms |
2924 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
2924 KB |
Output is correct |
2 |
Correct |
18 ms |
2924 KB |
Output is correct |
3 |
Correct |
18 ms |
2924 KB |
Output is correct |
4 |
Correct |
17 ms |
2924 KB |
Output is correct |
5 |
Correct |
17 ms |
2924 KB |
Output is correct |
6 |
Correct |
17 ms |
2924 KB |
Output is correct |
7 |
Correct |
17 ms |
2924 KB |
Output is correct |
8 |
Correct |
17 ms |
2924 KB |
Output is correct |
9 |
Correct |
17 ms |
2924 KB |
Output is correct |
10 |
Correct |
17 ms |
2924 KB |
Output is correct |
11 |
Correct |
17 ms |
2924 KB |
Output is correct |
12 |
Correct |
17 ms |
2924 KB |
Output is correct |
13 |
Correct |
17 ms |
2924 KB |
Output is correct |
14 |
Correct |
18 ms |
2924 KB |
Output is correct |
15 |
Correct |
21 ms |
2924 KB |
Output is correct |
16 |
Correct |
19 ms |
2924 KB |
Output is correct |
17 |
Correct |
17 ms |
2924 KB |
Output is correct |
18 |
Correct |
17 ms |
2924 KB |
Output is correct |
19 |
Correct |
17 ms |
2924 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
117 ms |
5484 KB |
Output is correct |
2 |
Correct |
122 ms |
5504 KB |
Output is correct |
3 |
Correct |
121 ms |
5560 KB |
Output is correct |
4 |
Correct |
137 ms |
5484 KB |
Output is correct |
5 |
Correct |
116 ms |
5484 KB |
Output is correct |
6 |
Correct |
118 ms |
5484 KB |
Output is correct |
7 |
Correct |
115 ms |
5484 KB |
Output is correct |
8 |
Correct |
119 ms |
5484 KB |
Output is correct |
9 |
Correct |
118 ms |
5484 KB |
Output is correct |
10 |
Correct |
118 ms |
5484 KB |
Output is correct |
11 |
Correct |
112 ms |
5612 KB |
Output is correct |
12 |
Correct |
113 ms |
5484 KB |
Output is correct |
13 |
Correct |
153 ms |
5484 KB |
Output is correct |
14 |
Correct |
137 ms |
5536 KB |
Output is correct |
15 |
Correct |
107 ms |
4716 KB |
Output is correct |
16 |
Correct |
119 ms |
5484 KB |
Output is correct |
17 |
Correct |
117 ms |
5484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1289 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |