Skip to content

Commit

Permalink
6/26 PS
Browse files Browse the repository at this point in the history
  • Loading branch information
ChoiEungi committed Jun 25, 2021
1 parent be67bb2 commit b0404c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 24 deletions.
3 changes: 3 additions & 0 deletions choieungi/NewThisIsCT/12-1 럭키 스트레이트.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
s = [*map(int, input())]
l = len(s)//2
print("READY"if sum(s[:l])-sum(s[l:])else"LUCKY")
27 changes: 3 additions & 24 deletions choieungi/main.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
import heapq


def solution(food_times, k):
if sum(food_times) <= k: return -1

idx_food_times = [[food, idx + 1] for idx, food in enumerate(food_times)]
heapq.heapify(idx_food_times)
previous, sum_val = 0, 0
length = len(idx_food_times)

while True:
if (idx_food_times[0][0] - previous) * length <= k - sum_val:
food_time = heapq.heappop(idx_food_times)[0]
sum_val += (food_time - previous) * length
previous = food_time
length -= 1

else:
ret = sorted(idx_food_times, key=lambda x: x[1])
return ret[(k - sum_val) % len(idx_food_times)][1]


print(solution([8,6,4], 15))
s = [*map(int, input())]
l = len(s)//2
print("READY"if sum(s[:l])-sum(s[l:])else"LUCKY")

0 comments on commit b0404c8

Please sign in to comment.