Skip to content

Commit

Permalink
✨feat: [BOJ] 04_6236_용돈관리- 파이썬
Browse files Browse the repository at this point in the history
  • Loading branch information
JeonHyoChang committed Mar 12, 2023
1 parent dfb87c8 commit 7edf7e8
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions JeonHyoChang/week_03/BOJ_6236_용돈관리.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import sys


def checkM(s):
temp = s
count = 1
for i in moneyOfDay:
if temp - i < 0:
count += 1
temp = s - i
else:
temp -= i

return count


N, M = map(int, sys.stdin.readline().split())
moneyOfDay = list()
for _ in range(N):
moneyOfDay.append(int(sys.stdin.readline()))

start = max(moneyOfDay)
end = sum(moneyOfDay)

while start <= end:
mid = (start + end) // 2
#print(start, mid, end, checkM(mid))
if checkM(mid) > M:
start = mid + 1
else:
end = mid - 1

print(start)

0 comments on commit 7edf7e8

Please sign in to comment.