Skip to content

Commit

Permalink
Merge pull request #268 from AlgoLeadMe/87-tgyuuAn
Browse files Browse the repository at this point in the history
87-tgyuuAn
  • Loading branch information
tgyuuAn authored Feb 3, 2025
2 parents e303da0 + 0bb26e7 commit c8cefc2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions tgyuuAn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,5 @@
| 84차시 | 2024.12.31 | BFS | <a href="https://www.acmicpc.net/problem/4179">불!</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/261
| 85차시 | 2025.01.09 | 다익스트라 + 이분 탐색 | <a href="https://www.acmicpc.net/problem/1800">인터넷 설치</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/264
| 86차시 | 2025.01.16 | 이분 탐색 | <a href="https://www.acmicpc.net/problem/1114">통나무 자르기</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/265
| 87차시 | 2025.01.31 | 그리디 | <a href="https://www.acmicpc.net/problem/8980">택배</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/268
---
30 changes: 30 additions & 0 deletions tgyuuAn/그리디/택배.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit c8cefc2

Please sign in to comment.