Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

40-H0ngJu #267

Merged
merged 2 commits into from
Feb 3, 2025
Merged

40-H0ngJu #267

merged 2 commits into from
Feb 3, 2025

Conversation

H0ngJu
Copy link
Collaborator

@H0ngJu H0ngJu commented Jan 27, 2025

πŸ”— 문제 링크

흙길 λ³΄μˆ˜ν•˜κΈ°

βœ”οΈ μ†Œμš”λœ μ‹œκ°„

30M

✨ μˆ˜λ„ μ½”λ“œ

μ˜€λžœλ§Œμ— 30λΆ„ μ»·!! ν•œ λ¬Έμ œμž…λ‹ˆλ‹€.
체감 λ‚œμ΄λ„ silver..



일단 물웅덩이 정보듀을 μ •λ ¬ν•΄μ£Όμ–΄μ•Ό ν•©λ‹ˆλ‹€.


μ•žλ’€κ°€ μ„žμ—¬μžˆλŠ” μƒν™©μ—μ„œλŠ” 이전 λ„λΉ€μ§€μ˜ μ‹œμž‘, 끝점을 νŒŒμ•…ν•  수 μ—†κΈ° λ•Œλ¬Έμž…λ‹ˆλ‹€.


정렬을 ν•œ 웅덩이 정보듀 μ†μ—μ„œ,

이전 널빀지λ₯Ό 계속 μ‚¬μš©ν•  수 μ—†λŠ” 경우 에 μ΄ˆμ μ„ λ§žμΆ°μ„œ
λ‘œμ§μ„ κ΅¬μ„±ν•˜λ©΄ λ©λ‹ˆλ‹€.


λ§Œμ•½, 이전 널빀지λ₯Ό μ‚¬μš©ν•  수 μ—†λ‹€λ©΄
= 이전 λ„λΉ€μ§€μ˜ 끝이 ν˜„μž¬ 물웅덩이 λκΉŒμ§€ λ„λ‹¬ν•˜μ§€ μ•ŠλŠ” 경우이면,

(물웅덩이 끝 - μ‹œμž‘) / L만큼 널빀지가 ν•„μš”ν•˜κ³ , 이전 널빀지λ₯Ό κ°±μ‹ ν•΄μ€λ‹ˆλ‹€.



λ‹€λ§Œ,
μ—¬κΈ°μ„œ μ£Όμ˜ν•  점은 이전 널빀지가 μ›…λ©μ΄μ˜ μΌλΆ€λ§Œ 가릴 수 μžˆλŠ” 경우λ₯Ό
μΆ”κ°€μ μœΌλ‘œ μ²˜λ¦¬ν•΄μ£Όλ©΄ λμž…λ‹ˆλ‹€!!



ps. 문제의 힌트
μ—μ„œλŠ” 0λΆ€ν„° 널빀지λ₯Ό κΉ”μ•„μ£Όκ³  μžˆμ§€λ§Œ,
μ €λŠ” 물웅덩이 μ‹œμž‘λΆ€ν„° κΉ”μ•„μ£Όμ—ˆμ–΄μš”. 이 뢀뢄에 λŒ€ν•΄μ„œλŠ” 닡을 κ΅¬ν•˜λŠ”λ°λŠ” λ¬Έμ œκ°€ μ—†λŠ” 것 κ°™μ•„μš”.
널빀지λ₯Ό κΉ” 수 μžˆλŠ” μΌ€μ΄μŠ€κ°€ μ—¬λŸ¬κ°œλ‹€... 정도 인듯 ν•©λ‹ˆλ‹€!

ν•΄ν”Ό μ„€λ‚ μ΄λ‹ˆκΉŒ 쑰금 μ‰¬μš΄ λ¬Έμ œλΌλ„ ... γ…Ž..γ…Ž.γ…Ž.γ…Ž..

πŸ“š μƒˆλ‘­κ²Œ μ•Œκ²Œλœ λ‚΄μš©

Copy link
Member

@tgyuuAn tgyuuAn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import sys
import math

def input(): return sys.stdin.readline()

N,L = map(int, input().split())

pools = []

for _ in range(N):
    start, end = map(int, input().split())
    pools.append((start, end))
    
pools.sort()

answer = 0
previous = 0
for pool in pools:
    start, end = pool
    start = max(start, previous)
    
    gap = (end - start)
    need = math.ceil(gap/L)
    previous = start + (L * need)
    answer += need
    
print(answer)

ν•΄ν”Ό 섀날이라고 곡짜문제λ₯Ό!!!!

5λΆ„μ»· 히히히히히히히

@H0ngJu H0ngJu merged commit e303da0 into main Feb 3, 2025
@H0ngJu H0ngJu deleted the 40-H0ngJu branch February 3, 2025 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants