We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 31e887e commit 7a2ce85Copy full SHA for 7a2ce85
kojungbeom/Programmers/Level2/다리를 지나는 트럭.py
@@ -0,0 +1,17 @@
1
+def solution(bridge_length, weight, truck_weights):
2
+ bridge = []
3
+ all_weight = 0
4
+ t = 0
5
+ while truck_weights or bridge:
6
+ t += 1
7
+
8
+ if bridge and t - bridge[0][1] == bridge_length:
9
+ truck, _ = bridge.pop(0)
10
+ all_weight -= truck
11
12
+ if truck_weights and all_weight + truck_weights[0] <= weight:
13
+ truck = truck_weights.pop(0)
14
+ bridge.append([truck, t])
15
+ all_weight += truck
16
17
+ return t
0 commit comments