일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- python
- 자바
- divmod
- 추석맞이 코딩챌린지
- KAKAO BLIND RECRUITMENT
- 백준
- 동적 계획법
- lambda
- 정렬
- 위클리 챌린지
- BFS
- 수학
- backjoon
- 그리디
- DateTime
- 정규식
- Set
- 이분탐색
- Combinations
- 재귀함수
- 카카오
- Re
- programmers
- 다익스트라
- 파이썬
- Zip
- java
- dfs
- 프로그래머스
- heapq
Archives
- Today
- Total
상상쓰
[프로그래머스] [1차] 추석 트래픽 본문
https://programmers.co.kr/learn/courses/30/lessons/17676
코딩테스트 연습 - [1차] 추석 트래픽
입력: [ "2016-09-15 20:59:57.421 0.351s", "2016-09-15 20:59:58.233 1.181s", "2016-09-15 20:59:58.299 0.8s", "2016-09-15 20:59:58.688 1.041s", "2016-09-15 20:59:59.591 1.412s", "2016-09-15 21:00:00.464 1.466s", "2016-09-15 21:00:00.741 1.581s", "2016-09-1
programmers.co.kr
계산하기 쉽게 밀리초로 표현한 후, process의 각 원소의 끝나는 시각에서 시작했을 때의 처리량을 구하여 그 중 최댓값을 구하면 된다.
def solution(lines):
answer = 1
process = []
for i in lines:
D, T, S = i.split(' ')
h, m, s = T.split(':')
end = (int(h) * 3600 + int(m) * 60 + float(s)) * 1000
start = end - (float(S.replace('s', ''))) * 1000 + 1
process.append([int(start), int(end)])
for j in range(0, len(process)-1):
c = 1
start = process[j][1]
end = start + 999
for k in range(j+1, len(process)):
if end >= process[k][0]:
c = c + 1
if answer < c:
answer = c
return answer
print(solution(['2016-09-15 01:00:04.001 2.0s', '2016-09-15 01:00:07.000 2s'])) # 1
'Coding Test' 카테고리의 다른 글
[백준] 컵홀더 (0) | 2021.07.14 |
---|---|
[백준] 8진수 2진수 (0) | 2021.07.13 |
[백준] 크게 만들기 (0) | 2021.07.12 |
[프로그래머스] 거리두기 확인하기 (0) | 2021.07.11 |
[프로그래머스] 호텔 방 배정 (0) | 2021.07.09 |
Comments