import sys
sys.stdin = open('input.txt', 'rt')
input = sys.stdin.readline
N, H = map(int, input().split())
rooms = []
for _ in range(N):
rooms.append(list(map(int, input().split())))
start = 1
end = 1000000
while start <= end:
max_hp = (start + end) // 2 # 이분탐색의 중간값 여기선 최대 hp이므로 max_hp로 변수명 설정
monster_hp = 0
monster_attack = 0
current_attack = H
current_hp = max_hp
print(max_hp)
for room in rooms:
if room[0] == 1:
temp = room[2] // current_attack
if room[2] % current_attack != 0:
temp = temp + 1
current_hp = current_hp - (temp * room[1])
else:
current_attack = current_attack + room[1]
current_hp = current_hp + room[2]
if current_hp <= 1:
start = max_hp + 1
else:
answer = max_hp
end = max_hp - 1
print(answer)
코드 임시 저장..