diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..035c31a0 Binary files /dev/null and b/.DS_Store differ diff --git "a/Baekjoon - \353\254\270\354\240\234\355\222\200\354\235\264/RGB\352\261\260\353\246\254/jamin.py" "b/Baekjoon - \353\254\270\354\240\234\355\222\200\354\235\264/RGB\352\261\260\353\246\254/jamin.py" new file mode 100644 index 00000000..ad5bd72f --- /dev/null +++ "b/Baekjoon - \353\254\270\354\240\234\355\222\200\354\235\264/RGB\352\261\260\353\246\254/jamin.py" @@ -0,0 +1,11 @@ +n = int(input()) +RGB = [] +for i in range(n): + RGB.append(list(map(int,input().split()))) + +for i in range(1,len(RGB)): + RGB[i][0] = min(RGB[i-1][1],RGB[i-1][2])+RGB[i][0] + RGB[i][1] = min(RGB[i-1][0],RGB[i-1][2])+RGB[i][1] + RGB[i][2] = min(RGB[i-1][1],RGB[i-1][0])+RGB[i][2] + +print(min(RGB[n-1][0],RGB[n-1][1],RGB[n-1][2])) \ No newline at end of file diff --git "a/Baekjoon - \353\254\270\354\240\234\355\222\200\354\235\264/\353\205\271\354\203\211 \354\230\267 \354\236\205\354\235\200 \354\225\240\352\260\200 \354\240\244\353\213\244\354\247\200?/jamin.py" "b/Baekjoon - \353\254\270\354\240\234\355\222\200\354\235\264/\353\205\271\354\203\211 \354\230\267 \354\236\205\354\235\200 \354\225\240\352\260\200 \354\240\244\353\213\244\354\247\200?/jamin.py" new file mode 100644 index 00000000..c575a7be --- /dev/null +++ "b/Baekjoon - \353\254\270\354\240\234\355\222\200\354\235\264/\353\205\271\354\203\211 \354\230\267 \354\236\205\354\235\200 \354\225\240\352\260\200 \354\240\244\353\213\244\354\247\200?/jamin.py" @@ -0,0 +1,30 @@ +import sys +from heapq import heappush,heappop +input = sys.stdin.readline +dx = [-1,1,0,0] +dy = [0,0,-1,1] + +case = 1 + +while True: + N = int(input()) + if N == 0: + break + cave = [list(map(int,input().split())) for _ in range(N)] + visited = [[-1 for _ in range(N)]for _ in range(N)] + heap = [] + heappush(heap,[cave[0][0],0,0]) + visited[0][0] = 0 + while heap: + answer,x,y = heappop(heap) + if [x,y] == [N-1,N-1]: + print("Problem",case,end = "") + print(":",answer) + for i in range(4): + ax = x + dx[i] + ay = y + dy[i] + if 0<= ax < N and 0 <= ay < N: + if visited[ax][ay] == -1: + heappush(heap, [answer+cave[ax][ay],ax,ay]) + visited[ax][ay] = 0 + case += 1 \ No newline at end of file