Skip to content

Commit

Permalink
2025-01-31
Browse files Browse the repository at this point in the history
  • Loading branch information
tgyuuAn committed Jan 31, 2025
1 parent 742bec7 commit 0bb26e7
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 @@ -87,4 +87,5 @@
| 83차시 | 2024.12.01 | 수학 + 구현 | <a href="https://www.acmicpc.net/problem/1033">칵테일</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/259
| 84차시 | 2024.12.31 | BFS | <a href="https://www.acmicpc.net/problem/4179">불!</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/261
| 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 0bb26e7

Please sign in to comment.