https://www.acmicpc.net/problem/1931
1931λ²: νμμ€ λ°°μ
(1,4), (5,7), (8,11), (12,14) λ₯Ό μ΄μ©ν μ μλ€.
www.acmicpc.net
n = int(input())
time = []
for i in range(n):
start, end = map(int, input().split())
time.append((end, start))
time.sort()
cnt = 0
end = 0
for i in range(n):
if time[i][1] >= end:
cnt += 1
end = time[i][0]
print(cnt)
1. νμμκ°μ λλλ μκ° μ - μμ μκ° μμΌλ‘ μ λ ¬ν ν
2. 리μ€νΈ(μκ°) λ΄μμ μ°¨λ‘λλ‘ λ°λ³΅λ¬Έμ λλ©΄μ μμ μκ°μ΄ λλλ μκ°λ³΄λ€ κ°κ±°λ ν¬λ©΄ cnt + 1
λλλ μκ°μΌλ‘ λ¨Όμ μ λ ¬νκΈ° μν΄ λ¦¬μ€νΈ λ΄μ μκ°μ end - start μμΌλ‘ μ½μ νλ€!
'π€ > λ°±μ€' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
λ°±μ€ 1026: 보물 (Python) (0) | 2021.09.29 |
---|---|
λ°±μ€ 1541: μμ΄λ²λ¦° κ΄νΈ (Python) (0) | 2021.09.27 |
λ°±μ€ 11047: λμ 0 (Python) (0) | 2021.09.25 |
λ°±μ€ 11399: ATM (Python) (0) | 2021.09.25 |
λ°±μ€ 18870: μ’ν μμΆ (Python) (0) | 2021.09.15 |