[softeer] [21년 재직자 대회 예선] 회의실 예약 (python)

2022. 9. 12. 21:40·Study/algorithm
728x90
반응형

https://softeer.ai/practice/info.do?idx=1&eid=626 

 

Softeer

연습문제를 담을 Set을 선택해주세요. 취소 확인

softeer.ai


문제 회고

각 회의실마다 각 시간별로 스케줄을 만들어서 예약이 될 때마다 그 시간엔 예약이 되었다고 입력해준다.

busy를 사용해서 회의실이 이미 예약 되었는지 체크를 한다.


import sys

n, m = map(int, sys.stdin.readline().split())
room = {sys.stdin.readline().strip(): [False] * 10 for _ in range(n)}

for _ in range(m):
    r, s, e = sys.stdin.readline().split()
    s, e = int(s) - 9, int(e) - 9
    busy = False
    for i in range(s, e):
        if room[r][i]:
            busy = True
            break
    if not busy:
        for i in range(s, e):
            room[r][i] = True
room_names = sorted(list(room.keys()))
for r in room_names:
    print(f'Room {r}:')
    busy = True
    time = []
    index = 0
    while index < 10:
        if room[r][index] == False:
            for j in range(index + 1, 10):
                if room[r][j] == True or (j == 9 and room[r][j] == False):
                    busy = False
                    time.append((index + 9, j + 9))
                    index = j
                    break

        index += 1
    
    if not busy:
        print(f'{len(time)} available:')
        for t in time:
            start, end = str(t[0]).zfill(2), str(t[1]).zfill(2)
            print(f'{start}-{end}')
    else:
        print('Not available')
    if r != room_names[-1]:
        print('-----')
728x90
반응형

'Study > algorithm' 카테고리의 다른 글

[softeer] [인증평가(4차) 기출] 슈퍼컴퓨터 클러스터 (python)  (1) 2022.09.29
[softeer] [21년 재직자 대회 본선] 트럭 (python)  (0) 2022.09.14
[softeer] [21년 재직자 대회 예선] 이미지 프로세싱 (python)  (0) 2022.09.05
[programmers] 합승 택시 요금 (python)  (0) 2022.09.02
[softeer] [인증평가(1차) 기출] 로봇이 지나간 경로 (python)  (0) 2022.09.02
'Study/algorithm' 카테고리의 다른 글
  • [softeer] [인증평가(4차) 기출] 슈퍼컴퓨터 클러스터 (python)
  • [softeer] [21년 재직자 대회 본선] 트럭 (python)
  • [softeer] [21년 재직자 대회 예선] 이미지 프로세싱 (python)
  • [programmers] 합승 택시 요금 (python)
성장형감자
성장형감자
공부 기록
    반응형
  • 성장형감자
    단순하게
    성장형감자
  • 전체
    오늘
    어제
    • Category (66)
      • Paper review (38)
        • 2D Object detection (11)
        • 3D Object detection (20)
        • 2D Segmentation (1)
        • 2D Classification (5)
        • 3D classification (1)
      • Programming (4)
        • Python (1)
        • Linux (3)
      • Project (0)
      • Study (24)
        • algorithm (20)
        • etc. (1)
        • Radar (3)
  • 인기 글

  • 블로그 메뉴

    • 홈
  • 250x250
  • hELLO· Designed By정상우.v4.10.0
성장형감자
[softeer] [21년 재직자 대회 예선] 회의실 예약 (python)
상단으로

티스토리툴바