Skip to content

Commit 0d02a2d

Browse files
committed
[BOJ]#13335트럭/ Gold/ 실패
https://www.acmicpc.net/problem/13335
1 parent b8f3db6 commit 0d02a2d

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

Hongjoo/백준/트럭.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
'''
2-
Condition
3-
1. 다리 - 최대 하중 L , 최대 개수 W , 길이 W
4-
-단위 시간 에 거리
5-
6-
'''
1+
# 실패
72
import sys
8-
# 1. 입력 - 버스 개수 , 다리 길이 , 다리 최대 하중
9-
N , W , L = map(int, sys.stdin.readline.splite())
10-
buses = map(int, sys.stdin.readline.splite())
11-
#2. 매 time 마다 bridge 최대 하중을 넘지 않은채 올리기
3+
n, w, l = map(int, sys.stdin.readline().split())
4+
truck = list(map(int, sys.stdin.readline().split()))
5+
time, bridge = 0, [0]*w #1. 시간변수와 다리의 길이를 입력받은 횟수만큼 리스트에 저장
6+
while bridge: #2. 다리의 길이가 0이 아닐때까지 반복
7+
time += 1 #3 time +1
8+
bridge.pop(0) #4.다리의 첫번째 원소 제거
9+
if truck: #5.bridge리스트를 추가하는건 truck리스트가 남아있을때까지
10+
if sum(bridge) + truck[0] <= l: #6기존 다리의 원소의 합 + 가장 왼쪽의 트럭'이 다리의 최대하중과 같거나 작다면.
11+
bridge.append(truck.pop(0))
12+
else: #7. 다리에 트럭이 있지만 다리에 올리지 못할 경우 다리 공간 유지하기 위해 0을 삽입
13+
bridge.append(0)
14+
print(time)

0 commit comments

Comments
 (0)