Question: sland Hopping with Treasure / Problem Statement You're a pirate captain with a treasure map. The map shows islands connected by bridges, and each island
sland Hopping with Treasure
Problem Statement
You're a pirate captain with a treasure map. The map shows islands connected by bridges, and each island has treasure.
You need to plan a treasure hunting trip with the following rules:
You can only visit one island at a time.
You can only travel between islands using the bridges.
Once you leave an island, you can't go back to it
Some islands might have more than one bridge connecting them.
Your task is to start at a specific island and end at another specific island, visiting other islands along the way. The gr to collect as much treasure as possible in the shortest amount of time.
Note: There are no cycles in the graph the graph is a DAG
Input Format
The first line of input contains three spaceseparated integers N M and K representing the number of islands, t number of bridges, and the number of startingending island pairs respectively.
The second line contains N spaceseparated integers TN representing the amount of treasure island.
The next M lines each contain three spaceseparated integers U V and W representing a bridge between isli V with travel time W
The next K lines each contain two spaceseparated integers S and E representing a starting island S and ar island E
Output Format
Constraints
N
M
Tg
UVS ESN
W
K$
Sample Testcase
Testcase Input
Sample Testcase
Testcase Input
Testcase Output
Explanation
One possible path is The treasures collected are and th
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
