D2
Problem
SW Expert Academy μλ‘μ΄ λ²μ€ λ Έμ
SW Expert Academy
SW νλ‘κ·Έλλ° μλ κ°νμ λμμ΄ λλ λ€μν νμ΅ μ»¨ν μΈ λ₯Ό νμΈνμΈμ!
swexpertacademy.com
Solution
1. 1λ²λΆν° 1000λ²κΉμ§ λ²μ€μ λ₯μ₯μ΄ μ ν΄μ Έ μμΌλ―λ‘ λ²μ€μ λ₯μ₯ 리μ€νΈλ₯Ό λ§λ€μ΄ μ΄μ©νμ
2. μΌλ°, κΈν, κ΄μ λ²μ€ λ³ μ‘°κ±΄μ΄ λλ μ Έμμ§λ§, κ²°κ³Όμ μΌλ‘ μ§λκ°λ κ³³μ 체ν¬ν ν μ΅λκ°μ ꡬνλ©΄ λλ€.
3. 쑰건μ νμΈνμ.
- μΌλ°λ²μ€: λͺ¨λ μ§λκ°
- κΈνλ²μ€: μμμ΄ μ§μ/νμ μ λ°λΌ μ§μ/νμ λ²λ§ μ§λκ°λ€.
- κ΄μλ²μ€:
- νμ: 3μ λ°°μμ΄λ©΄μ 10λ°°μκ° μλ κ³³
- μ§μ: 4μ λ°°μμΈ κ³³
- λ¨, μμμ κ³Ό λμ μ λ°λμ ν¬ν¨λλ€! λ°λΌμ μμκ³Ό λμ 쑰건μ λ¬μμ£Όμ.
Code
for test_case in range(1, int(input())+1):
N = int(input()) # λ
Έμ μ
bus_stop = [0] * 1001
for _ in range(N): # μ
λ ₯κ³Ό λμμ μ²λ¦¬
t, start, end = map(int, input().split())
if t == 1: # μΌλ° λ²μ€
for i in range(start, end+1):
bus_stop[i] += 1
elif t == 2: # κΈν λ²μ€
if start % 2 and not end % 2: # Bμ λ₯μ₯μ΄ ν¬ν¨ μ λλ κ²½μ° ν¬ν¨μν€κΈ°
bus_stop[end] += 1
elif not start % 2 and end % 2:
bus_stop[end] += 1
for i in range(start, end+1, 2): # νμ, μ§μ λͺ¨λ 2μ© μ»€μ§λ©΄ λ¨
bus_stop[i] += 1
elif t == 3: # κ΄μλ²μ€
if start % 2: # Aκ° νμμΈ κ²½μ°
for i in range(start, end+1):
if not i % 3 and i % 10:
bus_stop[i] += 1
if end % 3 or not end % 10: # Bκ° ν¬ν¨λμ§ μμ κ²½μ° ν¬ν¨μν€κΈ°
bus_stop[end] += 1
else: # Aκ° μ§μμΈ κ²½μ°
for i in range(start, end+1):
if not i % 4:
bus_stop[i] += 1
if end % 4: # Bκ° ν¬ν¨λμ§ μμ κ²½μ° ν¬ν¨μν€κΈ°
bus_stop[end] += 1
print(f'#{test_case} {max(bus_stop)}')
<λΆμ‘±ν λΆλΆμ λκΈλ‘ λ¨κ²¨μ£Όμλ©΄ μ μκ² ν° νμ΄ λ©λλ€!>
λ°μν
'π STUDY > μλ£κ΅¬μ‘° & μκ³ λ¦¬μ¦' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
| [μκ³ λ¦¬μ¦] Union-Find (1) | 2024.01.07 |
|---|---|
| 1717. μ§ν©μ νν (2) | 2024.01.07 |
| 4613. λ¬μμ κ΅κΈ° κ°μ κΉλ° (0) | 2023.03.06 |
| 1210. [S/W λ¬Έμ ν΄κ²° κΈ°λ³Έ] 2μΌμ°¨ - Ladder1 (0) | 2023.03.06 |
| 1954. λ¬ν½μ΄ μ«μ (0) | 2023.03.06 |