문제) 백준 - 문자열 - 싸이버개강총회
https://www.acmicpc.net/problem/19583
19583번: 싸이버개강총회
첫번째 줄에는 개강총회를 시작한 시간 S, 개강총회를 끝낸 시간 E, 개강총회 스트리밍을 끝낸 시간 Q가 주어진다. (00:00 ≤ S < E < Q ≤ 23:59) 각 시간은 HH:MM의 형식으로 주어진다. 두번째 줄부터는
www.acmicpc.net
S, E, Q의 숫자를 차례로 받고 시간 T와 이름의 입력을 받습니다. 정해진 입력 범위가 없기 때문에 밑의 코드와 같이 입력을 받습니다.
while True:
try:
T, Name = input().split()
except:
break
그 후 시간 비교를 통해 출석 여부를 판단합니다. 따로 시간 Tokenizing 후 과정 없이 비교 연산자만으로도 비교할 수 있습니다.(파이썬 개사기...)
Python 소스코드)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
input = sys.stdin.readline | |
S, E, Q = input().split() | |
li = dict() | |
while True: | |
try: | |
T, Name = input().split() | |
except: | |
break | |
if(T > Q): | |
break | |
if Name not in li.keys(): | |
li[Name] = 0 | |
if T <= S: | |
li[Name] = 1 | |
elif E <= T <= Q and li[Name] == 1: | |
li[Name] = 2 | |
ans = 0 | |
for n in li.keys(): | |
if li[n] == 2: | |
ans += 1 | |
print(ans) |
반응형
'PS(Problem Solving) > 백준_BOJ' 카테고리의 다른 글
[백준] 2160번 - 그림 비교 (C++) 문제 및 풀이 (0) | 2022.02.16 |
---|---|
[백준] 21937번 - 작업 (C++) 문제 및 풀이 (0) | 2022.02.15 |
[백준] 20207번 - 달력 (C++) 문제 및 풀이 (0) | 2022.02.14 |
[백준] 21939번 - 문제 추천 시스템 Version 1 (C++) 문제 및 풀이 (0) | 2022.02.14 |
[백준] 1145번 - 적어도 대부분의 배수 (C++) 문제 및 풀이 (0) | 2022.02.14 |
댓글