Notice
Recent Posts
Recent Comments
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 | 31 |
Tags
- ChatGPT
- 프로그래머스
- leetcode
- 맥북
- programmers
- 코로나19
- 파이썬
- Kaggle
- 백준
- AI 경진대회
- 우분투
- 더현대서울 맛집
- 금융문자분석경진대회
- 데이콘
- Real or Not? NLP with Disaster Tweets
- dacon
- 편스토랑
- ubuntu
- hackerrank
- github
- gs25
- 캐치카페
- PYTHON
- 자연어처리
- SW Expert Academy
- 편스토랑 우승상품
- Git
- Docker
- Baekjoon
- 프로그래머스 파이썬
Archives
- Today
- Total
솜씨좋은장씨
[Programmers] 힙 : 디스크 컨트롤러 (Python) 본문
728x90
반응형

1일 1문제 63일차!
오늘의 문제는 프로그래머스의 디스크 컨트롤러입니다!
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
Solution
def solution(jobs):
job_nums = len(jobs)
answer = 0
jobs.sort(key=lambda x: (x[0], x[1]))
start, time = jobs.pop(0)
end = time + start
answer = answer + time
while jobs:
next_index = 0
for index in range(1, len(jobs)):
if jobs[index][0] > end:
break
else:
if jobs[index][1] < jobs[next_index][1]:
next_index = index
next_ = jobs.pop(next_index)
if next_[0] <= end:
answer = answer + next_[1] + (end - next_[0])
end = end + next_[1]
else:
answer = answer + next_[1]
end = sum(next_)
return answer // job_nums
SOMJANG/CODINGTEST_PRACTICE
1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.
github.com
'Programming > 코딩 1일 1문제' 카테고리의 다른 글
| [Programmers] 해시 : 위장 (Python) (0) | 2020.04.11 |
|---|---|
| [BaekJoon] 1912번 : 연속합 (Python) (0) | 2020.04.10 |
| [BaekJoon] 9465번 : 스티커 (Python) (1) | 2020.04.08 |
| [HackerRank] Minimum Absolute Difference in an Array (Python) (1) | 2020.04.07 |
| [Programmers] 힙 : 더 맵게 (Python) (0) | 2020.04.06 |
Comments