Question: give the code in c + + , read the imput and ouput format properly, dont copy paste from anywhere, You need to travel from

give the code in c++, read the imput and ouput format properly, dont copy paste from anywhere, You need to travel from city 1 to city N across a land divided into N cities
connected by M undirected roads. Each road i(1iM) between cities Ui and Vi
has certain constraints, characterized by Ai entities each with Bi resistance points. The
travel time to cross this road at time t depends on these constraints: it takes |??Ai(t+1)??|+Bi
time units to overcome the entities and move on to city Vi, where the division is done
using integer division. You can start your journey at time 0 or any integer time unit
thereafter, and you can wait at any city for any integer amount of time. The goal is to
minimize the overall journey time. If it is not possible to reach city N, the result should
be -1. The task is to find the minimum time required to complete your journey.
Input :
First line of input consists of N and M(2N105,0M105).
The next M lines contain the description of the undirected roads.
The ith(1iM) line consists of
{:109).
Output :
Print the minimum time possible according to the problem statement.
Examples
Input :
Output :
3
By selecting the second road that links city 1 to city 2 and initiating the journey from
city 1 at time t=0, you can arrive in city 2 with a calculated time of
|??1(0+1)??|+2=3
units, where the division is integer division. Thus, the minimal travel time required to
reach city 2 is 3 units.
Input :
Output :
20
Hint :
ty=tx+|??Ai(tx+1)??|+Bi
tx is the time when you depart from city 'x' for city 'y'
give the code in c + + , read the imput and ouput

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 Programming Questions!