diff --git a/tgyuuAn/README.md b/tgyuuAn/README.md index ad6f690..2d06b35 100644 --- a/tgyuuAn/README.md +++ b/tgyuuAn/README.md @@ -88,4 +88,5 @@ | 84차시 | 2024.12.31 | BFS | 불! | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/261 | 85차시 | 2025.01.09 | 다익스트라 + 이분 탐색 | 인터넷 설치 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/264 | 86차시 | 2025.01.16 | 이분 탐색 | 통나무 자르기 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/265 +| 87차시 | 2025.01.31 | 그리디 | 택배 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/268 --- diff --git "a/tgyuuAn/\352\267\270\353\246\254\353\224\224/\355\203\235\353\260\260.py" "b/tgyuuAn/\352\267\270\353\246\254\353\224\224/\355\203\235\353\260\260.py" new file mode 100644 index 0000000..48ac4ec --- /dev/null +++ "b/tgyuuAn/\352\267\270\353\246\254\353\224\224/\355\203\235\353\260\260.py" @@ -0,0 +1,30 @@ +import sys + +def input(): return sys.stdin.readline().rstrip() + +N, C = map(int, input().split()) +M = int(input()) + +delieveries = [] +for _ in range(M): + start, destination, size = map(int, input().split()) + delieveries.append((start, destination, size)) + +delieveries.sort(key = lambda x : (x[1], x[0])) +table = [C for _ in range(N+1)] + +answer = 0 +previous_start = 0 +for delievery in delieveries: + start, destination, capacity = delievery + + can_delievery = capacity + for town in range(start, destination): + can_delievery = min(can_delievery, table[town]) + + for town in range(start, destination): + table[town] -= can_delievery + + answer += can_delievery + +print(answer) \ No newline at end of file