[파이썬] 백준 1946: 신입 사원 (그리디 알고리즘, 정렬)
2021.08.28 by \시엔/
[파이썬] 백준 5585: 거스름돈 (그리디 알고리즘)
[파이썬] 백준 2217: 로프 (그리디 알고리즘)
[파이썬] 백준 1946: 신입 사원 (그리디 알고리즘)
[파이썬] 백준 1931: 회의실 배정 (그리디 알고리즘)
# 신입사원 from sys import stdin t = int(stdin.readline()) # 테스트 케이스 개수 1~20 for i in range(t): cnt = 1 n = int(stdin.readline()) # 지원자의 숫자 people = [] for j in range(n): paper, interview = list(map(int, stdin.readline().split())) people.append([paper, interview]) people.sort() res = people[0][1] for j in range(n): if people[j][1] < res: cnt += 1 res = people[j][1] print(cnt)
백준 연습 2021. 8. 28. 20:47
# 거스름돈 import sys n = int(sys.stdin.readline()) n = 1000 - n lst = [500, 100, 50, 10, 5, 1] i = 0 cnt = 0 while n != 0: if n >= lst[i]: n = n - lst[i] cnt += 1 else: i += 1 print(cnt)
백준 연습 2021. 8. 28. 20:36
# 로프 from sys import stdin n = int(stdin.readline()) li = [] for i in range(n): li.append(int(stdin.readline())) res = [] li.sort() for i in range(n): res.append(li[i]*(n-i)) print(max(res))
백준 연습 2021. 8. 28. 20:34
# 신입사원 from sys import stdin from operator import itemgetter t = int(stdin.readline()) # 테스트 케이스 개수 1~20 for i in range(t): cnt = 1 n = int(stdin.readline()) # 지원자의 숫자 people = [] for j in range(n): paper, interview = list(map(int, input().split())) people.append([paper, interview]) people.sort(key=itemgetter(0)) res = people[0][1] for j in range(n): if people[j][1] < res: cnt += 1 res = people[..
백준 연습 2021. 8. 28. 20:32
from sys import stdin input = stdin.readline n = int(input()) graph = [] for i in range(n): graph.append(list(map(int, input().split()))) graph.sort() count = 0 for i in range(n): count = 0 j = i + 1 if j
백준 연습 2021. 8. 28. 20:31