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

37-H0ngJu #262

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

37-H0ngJu #262

wants to merge 1 commit into from

Conversation

H0ngJu
Copy link
Collaborator

@H0ngJu H0ngJu commented Dec 31, 2024

πŸ”— 문제 링크

νšŒμ˜μ‹€ λ°°μ •

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

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

image

문제λ₯Ό 보고 λΉ„μŠ·ν•œ λ¬Έμ œκ°€ ν•˜λ‚˜ λ– μ˜€λ₯΄λ”λΌκ³ μš”

#237 μš” λ¬Έμ œμž…λ‹ˆλ‹€!!



μ΅œλŒ€ν•œ 회의λ₯Ό 많~~~이 λ°°μ •ν•˜λ €λ©΄,

  1. 첫 회의λ₯Ό 일찍 μ‹œμž‘ν•΄μ•Όν•œλ‹€.
  2. 짧은 회의일 수둝 μœ λ¦¬ν•˜λ‹€.

이 두 쑰건을 κ°€μ§‘λ‹ˆλ‹€.



그리고 첫 νšŒμ˜κ°€ μ–Έμ œμ‹œμž‘ν•΄μ„œ, μ–Έμ œ λλ‚˜λƒ,

즉, 첫 회의λ₯Ό μ–΄λ–€ 것을 μž‘λŠλƒμ— λ”°λΌμ„œ μ‹œκ°„λ³΅μž‘λ„κ°€ 달라 질거라고 μ˜ˆμƒν–ˆμ–΄μš”.

κ·Έλ ‡κ²Œ μ²˜μŒμ—λŠ” μ‹œμž‘ μ‹œκ°„μ΄ λΉ λ₯Έ 순으둜, μ •λ ¬μ„ν•˜κ³  λ‘œμ§μ„ κ΅¬μ„±ν–ˆλ”λ‹ˆ,

1 11
1 5
5 6
11 12

와 같은 μΌ€μ΄μŠ€μ—μ„œλŠ” 닡이 3이 λ˜μ–΄μ•Ό ν•˜μ§€λ§Œ, 2κ°€ λ˜μ–΄λ²„λ¦¬λŠ” λ¬Έμ œκ°€ μƒκΉλ‹ˆλ‹€.


그런데,

항상 λͺ¨λ“  νšŒμ˜λŠ” λλ‚˜λŠ” μ‹œκ°„λ³΄λ‹€ μ‹œμž‘ μ‹œκ°„μ΄ μ΄λ¦…λ‹ˆλ‹€. (λ„ˆλ¬΄λ‚˜λ„ λ‹Ήμ—°νžˆ)

κ·Έλž˜μ„œ μ‹œμž‘μ‹œκ°„μ„ μ˜€λ¦„μ°¨μˆœμœΌλ‘œ μ •λ ¬ν•  것이 μ•„λ‹ˆλΌ,

νšŒμ˜κ°€ λλ‚˜λŠ” μ‹œκ°„μ„ μ˜€λ¦„μ°¨μˆœμœΌλ‘œ μ •λ ¬ ν•˜λŠ” 것이 이 문제의 ν•΅μ‹¬μž…λ‹ˆλ‹€.


μ•„λ‹ˆλ‚˜ λ‹€λ₯ΌκΉŒ

ν’€κ³  λΆ„λ₯˜λ³΄λ‹ˆκΉŒ 이번 λ¬Έμ œμ™€ #237 λ¬Έμ œκ°€ λ‘˜λ‹€ 그리디 + μ •λ ¬ λ¬Έμ œλ„€μš” !!

두 문제의 μ°¨μ΄λŠ” μ–΄λ–€ 것을 κΈ°μ€€μœΌλ‘œ μ •λ ¬ν–ˆλƒ? 정도인 것 κ°™μ•„μš”!



μ •λ ¬λ§Œ λ– μ˜¬λ¦¬λ©΄ λ‚˜λ¨Έμ§€λŠ” μ‰½κ²Œ μ²˜λ¦¬ν•  수 μžˆλŠ” 것 κ°™μŠ΅λ‹ˆλ‹€.

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

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

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

N = int(input())
meetings = []
for _ in range(N):
    start, end = map(int, input().split())
    meetings.append((start, end))
    
meetings.sort(reverse = True)
answer = 0
now = []
while meetings:
    now_start, now_end = meetings.pop()
    
    while now and now[-1][1] > now_end:
        now.pop()
    
    if not now or (now and now_start >= now[-1][1]):
        now.append((now_start, now_end))
        
    answer = max(answer, len(now))

print(answer)

홀리 μ’―~~~~~~~~~~~

λλ‚˜λŠ” μ‹œκ°„μœΌλ‘œ μ •λ ¬ν•˜λ©΄ κ·Έλƒ₯ μ½”λ“œ μ™„μ „ μ§§μ•„μ§€λ„€μš” ...

와 λŒ€λ°• ,,,,,,,,,,,,,,,,,,,,, 무릎 탁 치고 κ°‘λ‹ˆλ‹€.

μ €λŠ” 일일이 μ•žλ’€ λΉ„κ΅ν•˜λ©΄μ„œ λλ‚˜λŠ” μ‹œκ°„μ΄ 더 짧은걸 λ„£μ–΄μ£Όκ³  μžˆμ—ˆλ„€μš”...

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