Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 파이썬
- 다이나믹 프로그래밍
- BOJ
- dict
- level2
- 구현
- BFS
- programmers
- 그리디
- 운영체제
- level3
- 스택
- dfs
- 프로그래머스
- python
- 코딩테스트
- level1
- 수학
- level0
- DP
- 재귀
- 가상메모리 관리
- 백준
- 힙
- 딕셔너리
- MYSQL
- 브루트포스
- 다익스트라
- 가상메모리
- N과M
Archives
- Today
- Total
동캄의 코딩도장
백준 1263 [시간 관리] 파이썬 본문
https://www.acmicpc.net/problem/1263
1263번: 시간 관리
진영이는 캠프 조교를 온 후 효율적으로 시간 관리를 해야 한다는 것을 깨달았다. 진영이는 하루에 해야 할 일이 총 N개가 있고 이 일들을 편하게 1번부터 N번까지 차례대로 번호를 붙였다. 진영
www.acmicpc.net
#백준 1263
import sys
n=int(sys.stdin.readline())
lst=[]
for i in range(n):
s=list(map(int,sys.stdin.readline().split()))
lst.append(s)
lst.sort(key=lambda x:x[1])
ans=-1
start=lst[0][1]-lst[0][0]
if start<0:
print(ans)
else:
for time in range(start,-1,-1):
count=0
ini_time=time
for k in range(len(lst)):
if time+lst[k][0]<=lst[k][1]:
time+=lst[k][0]
count+=1
else:
break
if count==n:
ans=ini_time
break
if ini_time==0:
break
print(ans)
그리디 한 문제이다.
'코테 > BOJ' 카테고리의 다른 글
백준 16206 [롤케이크] 파이썬 (0) | 2022.09.05 |
---|---|
백준 2853 [배] 파이썬 (0) | 2022.09.05 |
백준 14002 [가장 긴 증가하는 부분 수열 4] 파이썬 (0) | 2022.09.05 |
백준 4796 [캠핑] 파이썬 (0) | 2022.09.05 |
백준 1105 [팔] 파이썬 (0) | 2022.09.05 |