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 |
Tags
- 우분투
- Docker
- 프로그래머스
- 편스토랑 우승상품
- leetcode
- ubuntu
- 파이썬
- PYTHON
- 맥북
- 더현대서울 맛집
- 자연어처리
- Git
- 백준
- 코로나19
- 편스토랑
- dacon
- programmers
- 금융문자분석경진대회
- ChatGPT
- Baekjoon
- 캐치카페
- Kaggle
- AI 경진대회
- github
- Real or Not? NLP with Disaster Tweets
- SW Expert Academy
- 데이콘
- gs25
- hackerrank
- 프로그래머스 파이썬
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 |