Submission #378140

# Submission time Handle Problem Language Result Execution time Memory
378140 2021-03-16T05:02:13 Z dia312 배열 탈출 (GA8_array) PyPy
49 / 100
431 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 42 ms 20136 KB Output is correct
2 Correct 42 ms 20168 KB Output is correct
3 Correct 42 ms 20296 KB Output is correct
4 Correct 43 ms 20168 KB Output is correct
5 Correct 39 ms 20168 KB Output is correct
6 Correct 48 ms 20168 KB Output is correct
7 Correct 39 ms 20168 KB Output is correct
8 Correct 39 ms 20168 KB Output is correct
9 Correct 40 ms 20168 KB Output is correct
10 Correct 41 ms 20168 KB Output is correct
11 Correct 40 ms 20168 KB Output is correct
12 Correct 41 ms 20168 KB Output is correct
13 Correct 49 ms 20168 KB Output is correct
14 Correct 40 ms 20168 KB Output is correct
15 Correct 40 ms 20188 KB Output is correct
16 Correct 39 ms 20168 KB Output is correct
17 Correct 39 ms 20168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 20168 KB Output is correct
2 Correct 42 ms 20168 KB Output is correct
3 Correct 41 ms 20168 KB Output is correct
4 Correct 42 ms 20168 KB Output is correct
5 Correct 48 ms 20168 KB Output is correct
6 Correct 40 ms 20168 KB Output is correct
7 Correct 43 ms 20168 KB Output is correct
8 Correct 41 ms 20116 KB Output is correct
9 Correct 40 ms 20168 KB Output is correct
10 Correct 40 ms 20168 KB Output is correct
11 Correct 42 ms 20168 KB Output is correct
12 Correct 42 ms 20168 KB Output is correct
13 Correct 41 ms 20168 KB Output is correct
14 Correct 41 ms 20168 KB Output is correct
15 Correct 43 ms 20168 KB Output is correct
16 Correct 42 ms 20168 KB Output is correct
17 Correct 47 ms 20168 KB Output is correct
18 Correct 42 ms 20168 KB Output is correct
19 Correct 40 ms 20168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 108 ms 25800 KB Output is correct
2 Correct 110 ms 25160 KB Output is correct
3 Correct 109 ms 25576 KB Output is correct
4 Correct 129 ms 25416 KB Output is correct
5 Correct 105 ms 25032 KB Output is correct
6 Correct 106 ms 24904 KB Output is correct
7 Correct 110 ms 24776 KB Output is correct
8 Correct 71 ms 22600 KB Output is correct
9 Correct 72 ms 22472 KB Output is correct
10 Correct 71 ms 22600 KB Output is correct
11 Correct 88 ms 22472 KB Output is correct
12 Correct 71 ms 22600 KB Output is correct
13 Correct 71 ms 22600 KB Output is correct
14 Correct 69 ms 22344 KB Output is correct
15 Correct 69 ms 22344 KB Output is correct
16 Correct 69 ms 22344 KB Output is correct
17 Correct 70 ms 22472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 431 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -