Marks :10
: 5 | : 0
A footwear company has N outlets having unique id from $$$0$$$ to $$$N-1$$$. The outlets are connected using the bi directional roads directly or via other outlets. There is a cost of stock transfer between the directly connected outlets. Initially, the warehouses were established at K outlets. As the demand of the products increases unexpectedly during the festival seasons, so the stocks need to be transferred quickly among the warehouses. The company has decided to provide the trucks to transport the stock from one warehouse to another but it puts extra overhead on the company. The company has decided to start the truck between the closest warehouses initially. The company wants to find the minimum stock transfer cost between any two warehouses which will be incurred on the company. Write an algorithm to find the minimum stock transfer cost between any two warehouses which will be overhead on the company.
The first line of the input consists of two space-separated integers - numOutlets and numWarehouses, representing the number of outlets ($$$2\leq N \leq 500$$$) and the number of warehouses($$$2 \leq K \leq N$$$). The next line consists of K space separated integers warehouse D[0], warehouse D[1]..., warehouse/D[K-1], representing the ids where the warehouses were established initially. The next line consists of an integer - directConnection, representing the number of direct connections among outlets ($$$X$$$). The next $$$X$$$ lines consists of three space-separated integers - $$$A, B, C$$$ representing the id of the directly connected outlets ($$$A$$$ and $$$B$$$) and the cost of stock transport $$$1\leq C \leq 1300$$$ between outlet $$$A$$$ and $$$B$$$.
Print an integer representing the minimum stock transfer cost between any two warehouses.
6 3 1 3 4 7 0 1 10 0 4 7 1 3 12 3 5 3 1 5 10 4 2 2 2 5 3
8
5 4 0 2 3 4 6 0 1 1249 0 3 209 0 4 609 1 3 73 2 4 703 3 4 1048
209
You need to login to view your submissions.
You need to login to view all submissions.
Result : Executed
Feel something is wrong with the test cases?
Result : Accepted
Test Cases :
But to Run or Submit the Problem, you need to Log In.
Continue to Log InYour challenge has been submitted successfully.
You will get a response soon via WhatsApp or Email.
Do let us know your issue.