728x90
λ¬Έμ
νμ΄
μ λ ₯μ΄ λ€μκ³Ό κ°μ λ,
200 2 5
100 150 10
110 150 15
μμμ λ²νΈλ 0 ~ 200κΉμ§ μλ€.
μ°μ μ€κ° κ°(100)μ ꡬνκ³ , 0λ² μμμμ 100λ² μμκΉμ§μ λν 리 κ°μλ₯Ό ꡬνλ€.
λν 리 κ°μμ λ°λΌ μ΄λΆ νμμ μννλ©΄ λλ€.
μ½λ
import sys
input = sys.stdin.readline
#λν 리 μ ꡬνκΈ°
def calAcorn(rules, boxNum):
cnt = 0
for start, end, margin in rules:
if boxNum < start:
continue
end = min(boxNum, end)
cnt += (end - start) // margin + 1
return cnt
def binarySearch(rules, end, find):
start = 0
while start < end:
mid = (start + end) // 2
midAcorn = calAcorn(rules, mid)
if midAcorn < find:
start = mid + 1
else:
end = mid
return start
n, k, d = map(int, input().split())
rules = []
for _ in range(k):
a, b, c = map(int, input().split())
rules.append((a, b, c))
print(binarySearch(rules, n, d))
λ§λ¬΄λ¦¬
골λ 2 μμ€μ μκ³ λ¦¬μ¦μ μλ κ² κ°λ€.
728x90