목록코딩 테스트/백준 문제 풀이 (107)
공부 기록장
https://www.acmicpc.net/problem/1449 1449번: 수리공 항승 첫째 줄에 물이 새는 곳의 개수 N과 테이프의 길이 L이 주어진다. 둘째 줄에는 물이 새는 곳의 위치가 주어진다. N과 L은 1,000보다 작거나 같은 자연수이고, 물이 새는 곳의 위치는 1,000보다 작거나 www.acmicpc.net 코드 import sys n, tapeLen = map(int, input().split()) pos = list(map(int, sys.stdin.readline().split())) pos.sort() start = pos[0] - 0.5 end = start + tapeLen cnt = 1 for i in range(0, len(pos)): if start < pos[i] <..
https://www.acmicpc.net/problem/13305 13305번: 주유소 표준 입력으로 다음 정보가 주어진다. 첫 번째 줄에는 도시의 개수를 나타내는 정수 N(2 ≤ N ≤ 100,000)이 주어진다. 다음 줄에는 인접한 두 도시를 연결하는 도로의 길이가 제일 왼쪽 도로부터 N-1 www.acmicpc.net 코드 import sys n = int(input()) road = list(map(int, sys.stdin.readline().split())) city = list(map(int, sys.stdin.readline().split())) price = city[0] liter = road[0] cost = 0 for i in range(1, n): if price > city[i..
https://www.acmicpc.net/problem/2217 2217번: 로프 N(1 ≤ N ≤ 100,000)개의 로프가 있다. 이 로프를 이용하여 이런 저런 물체를 들어올릴 수 있다. 각각의 로프는 그 굵기나 길이가 다르기 때문에 들 수 있는 물체의 중량이 서로 다를 수도 있다. 하 www.acmicpc.net 코드 # 모든 로프를 사용할 필요가 없다 import sys n = int(sys.stdin.readline()) rope = [] for i in range(n): rope.append(int(sys.stdin.readline())) rope.sort(reverse=True) mlist = [] while rope: rlen = len(rope) last = rope.pop() mlis..
https://www.acmicpc.net/problem/2839 2839번: 설탕 배달 상근이는 요즘 설탕공장에서 설탕을 배달하고 있다. 상근이는 지금 사탕가게에 설탕을 정확하게 N킬로그램을 배달해야 한다. 설탕공장에서 만드는 설탕은 봉지에 담겨져 있다. 봉지는 3킬로그 www.acmicpc.net 코드 n = int(input()) cnt = 0 while True: if n < 0: # N을 만들 수 없는 경우 cnt = -1 break if n % 5 == 0: cnt5 = n // 5 cnt += cnt5 break n -= 3 cnt += 1 if n == 0: break print(cnt) 5kg 봉지로 가져가면 가져가는 봉지의 개수를 줄일 수 있으므로, 최대한 5kg 봉지를 많이 써서 가져..