minyeamer
Minystory
minyeamer
edit settings
전체 방문자
오늘
어제
  • Category List (104)
    • Books (5)
      • Book Reviews (1)
      • Paper Reviews (4)
    • Life (4)
      • Blog (3)
      • Item Reviews (0)
      • Thoughts (1)
    • Study (37)
      • 2022 (3)
      • AI SCHOOL (34)
      • References (0)
    • Tech (58)
      • Algorithm (47)
      • Projects (9)
      • Python (2)

Blog Menu

  • Home
  • Notice
  • Tags
  • Guest

Popular Posts

Recent Comments

Recent Posts

hELLO
minyeamer

Minystory

Tech/Algorithm

[백준 1931] 회의실 배정 (Python)

2022. 8. 23. 11:32

문제 링크

  • https://www.acmicpc.net/problem/1931

문제 해설

Idea

  • Sliding Window
  • 슬라이딩 윈도우의 전형적인 문제로, 끝 시간을 기준으로 시간을 정렬해서 겹치지 않는 수를 계산

Time Complexity

  • O(N) = 100,000

Data Size

  • N: 1 <= int <= 100,000
  • t1,t2: 0 <= int <= 2^31-1

해설 코드

import sys
input = sys.stdin.readline

N = int(input())
times = sorted([tuple(map(int, input().split())) for _ in range(N)], key=lambda x: [x[1],x[0]])
count, end_time = 0, 0

for t1,t2 in times:
    if t1 >= end_time:
        count += 1
        end_time = t2

print(count)
저작자표시 (새창열림)

'Tech > Algorithm' 카테고리의 다른 글

[백준 7576] 토마토 (Python)  (0) 2022.08.24
[백준 18870] 좌표 압축 (Python)  (0) 2022.08.24
[백준 15686] 치킨 배달 (Python)  (0) 2022.08.23
[백준 1927] 최소 힙 (Python)  (0) 2022.08.22
[백준 1780] 종이의 개수 (Python)  (0) 2022.08.22
    'Tech/Algorithm' 카테고리의 다른 글
    • [백준 7576] 토마토 (Python)
    • [백준 18870] 좌표 압축 (Python)
    • [백준 15686] 치킨 배달 (Python)
    • [백준 1927] 최소 힙 (Python)
    minyeamer
    minyeamer
    Better than Yesterday

    티스토리툴바