Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 1 . Ada and hackathons Ada is planning to participate in N hackathons, numbered from 1 to N , scheduled in N different cities.
Ada and hackathons
Ada is planning to participate in N hackathons, numbered from to N scheduled in N different cities. The ith hackathon happens in city i Each hackathon j has a prerequisite: one should have participated in all hackathons indexed i j before participating in the hackathon j For example, if she wants to participate in hackathon she should have already participated in hackathons and
The N cities are connected by N bidirectional bus routes so that each city is reachable from the others by using one or more of these buses. The ticketing system for these bus routes is as follows: for each route, she can buy a single trip ticket for Ti coins or a season pass for Si coins. The singletrip ticket can be used only once, while the season ticket can be used any number of times for that bidirectional bus route.
Ada is currently at city She has already planned her trip and the tickets she would buy so that she can participate in all hackathons by spending the minimum amount on bus tickets. Can you find this minimum cost?
Input Format
The first line contains the number N
The next N lines describe the bus routes. Each line contains integers Ai Bj Ti Sj representing a bus route between city A and city Bi with the single trip ticket costing Ti coins and the season pass costing Si coins.
Constraints
N ThetaTheta
Ai N
Bi N
T e
Sje
Output Format
Print a single integer which is the minimum amount Ada would have to spend to participate in all hackathons assuming she is already in city
Sample Input
Sample Output
write code in c
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started