Answered step by step
Verified Expert Solution
Link Copied!

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.

11. Ada and hackathons
Ada is planning to participate in N hackathons, numbered from 1 to N, scheduled in N different cities. The ith hackathon happens in city i. Each hackathon j (>1) 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 4, she should have already participated in hackathons 1,2, and 3.
The N cities are connected by N-1 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 T_{i} coins or a season pass for S_{i} coins. The single-trip 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 1. 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-1 lines describe the bus routes. Each line contains 4 integers A_{i}, B_{j}, T_{i}, S_{j} representing a bus route between city A, and city B_{i} with the single trip ticket costing T_{i} coins and the season pass costing S_{i} coins.
Constraints
1<= N <=2Theta*Theta
1<= A_{i}<= N
1<= B_{i}<= N
1<= T <=1 e6
1<= S_{j}<=1e6
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 1.
Sample Input
4
1235
1324
2413
Sample Output
10

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions

Question

2. Darwins notes in biology.

Answered: 1 week ago

Question

600 lb 20 0.5 ft 30 30 5 ft

Answered: 1 week ago

Question

What is adverse impact? How can it be proved?

Answered: 1 week ago