Question: I will rate if this is implemented in python There is a cute little single-vehicle ferry that transports vehicles across a river. It begins each

 I will rate if this is implemented in python There is

I will rate if this is implemented in python

There is a cute little single-vehicle ferry that transports vehicles across a river. It begins each day on the West bank of the river. Vehicles arrive at various times throughout the day on either side of the river. But it can only hold one vehicle at a time The ferry operates as follows. If there are no vehicles waiting, it idles on the side it is currently resting on. At any time it is not currently transporting a vehicle, if some vehicle is waiting to be transported then it serves the vehicle that has been waiting the longest. It does this by first traveling to the side of the river the vehicle is waiting on (if the ferry is not there already). loading the vehicle, transporting it to the other side, and then unloading it The ferry operator is very single-minded. If he unloads a vehicle and if there are vehi cles waiting on both sides of the river but the next vehicle to be served (i.e. the one that has waited the longest) is on the other side, he travel to the other side without bringing over a vehicle from the current side. See examples 2 and 3 for clarification. Loading and unloading takes 0 time. The ferry takes 100 units of time to cross the river Again, recall the ferry starts on the West bank. What time is the last vehicle dropped off? npu The input consists of two lines. The first line consists of integers wl, u .. , wn lndicating the times the vehicles arrive on the west bank. The second line consists of integers el, e2,-.. , em indicating the times the vehicles arrive at the East bank. Both lists will already be in sorted order 1 Sn,m 100,000 and each time will be a positive integer at most 1,000, 000, 000. No two vehicles arrive at the bank at the same time. Output The output should be a single integer indicating the time the ferry drops the last vehicle off Sample Input 1 10 220 330 75 Sample Output 1 530 Explanation: At time 10, the ferry starts moving the first vehicle on the West bank and drops it off on the East bank at time 110. Immediately it picks up the vehicle that has beern waiting from time 75 and drops it off on the West bank at time 210 The ferry idles on the West bank until the next vehicle arrives at time 220. It transports this vehicle and drops it off at time 320. As no vehicles are currently at either bank, the ferry idles until the last vehicle arrives at 330. Once the ferry sees this vehicle at time 330 it first travels to the West bank to pick it up at time 430 and then drops it off on the East bank at time 530. There is a cute little single-vehicle ferry that transports vehicles across a river. It begins each day on the West bank of the river. Vehicles arrive at various times throughout the day on either side of the river. But it can only hold one vehicle at a time The ferry operates as follows. If there are no vehicles waiting, it idles on the side it is currently resting on. At any time it is not currently transporting a vehicle, if some vehicle is waiting to be transported then it serves the vehicle that has been waiting the longest. It does this by first traveling to the side of the river the vehicle is waiting on (if the ferry is not there already). loading the vehicle, transporting it to the other side, and then unloading it The ferry operator is very single-minded. If he unloads a vehicle and if there are vehi cles waiting on both sides of the river but the next vehicle to be served (i.e. the one that has waited the longest) is on the other side, he travel to the other side without bringing over a vehicle from the current side. See examples 2 and 3 for clarification. Loading and unloading takes 0 time. The ferry takes 100 units of time to cross the river Again, recall the ferry starts on the West bank. What time is the last vehicle dropped off? npu The input consists of two lines. The first line consists of integers wl, u .. , wn lndicating the times the vehicles arrive on the west bank. The second line consists of integers el, e2,-.. , em indicating the times the vehicles arrive at the East bank. Both lists will already be in sorted order 1 Sn,m 100,000 and each time will be a positive integer at most 1,000, 000, 000. No two vehicles arrive at the bank at the same time. Output The output should be a single integer indicating the time the ferry drops the last vehicle off Sample Input 1 10 220 330 75 Sample Output 1 530 Explanation: At time 10, the ferry starts moving the first vehicle on the West bank and drops it off on the East bank at time 110. Immediately it picks up the vehicle that has beern waiting from time 75 and drops it off on the West bank at time 210 The ferry idles on the West bank until the next vehicle arrives at time 220. It transports this vehicle and drops it off at time 320. As no vehicles are currently at either bank, the ferry idles until the last vehicle arrives at 330. Once the ferry sees this vehicle at time 330 it first travels to the West bank to pick it up at time 430 and then drops it off on the East bank at time 530

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!