You have just arrived in a new city and would like to see its sights. Each...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
You have just arrived in a new city and would like to see its sights. Each sight is located in a square and you have assigned each a beauty value. Each road to a square takes an amount of time to travel, and you have limited time for sightseeing. Determine the maximum value of beauty that you can visit during your time in the city. Start and finish at your hotel, the location of sight zero. Example n = 4 m = 3 %3! max_t = 50 beauty [5, 10, 15, 20] u = [0, 1, 0] v [1, 2, 3] t= [10, 10, 10] • n=4 squares are chosen in the map, including the hotel at square 0. • m= 3 bidirectional roads that connect them Edges are between squares uf] and vfi), and t [] is the time to travel edge i • beauty = (5, 10, 15, 20] represents the beauty values for squares 0, 1, 2, and 3 respectively. • To visit Square 0, 1 and 2 (Starting at the hotel and ending at the hotel), it takes 10 + 10 + 10 + 10 = 40 minutes and it has 5+ 10 + 15 30 beauty value (the beauty value is counted only on your first visit.) • To do a round trip from square 0 to square 3, it hackerrank.com/test/7tb6ldm4ljb/questions/c29hpks40a 20= %3D • To do a round trip from square 0 to square 3, it takes 10 + 10 -20 minutes and it has only 5+ 20%3D 25 beauty value. • The path that gathers squares with the maximum value of beauty that you can visit during max_t= 50 minutes or less, is squares = [0, 1, 2] with 30 as a beauty value. 10 1/10 2/15 10 0/5 10 3/20 Function Description Complete the function findBestPath in the editor below. findBestPath has the following parameter(s): int r. an integer, the number of sights in the city int m. an integer, the number of connecting roads int max t an integer, the amount of time for sightseeing int beauty[n). integer array, the beauty values you have assigned to each sight int u[m) integer array, the starting sight location for each bidirectional road int v[m). integer array, the ending sight location for each bidirectional road int t[m): integer array, the travel time for each bidirectional road Returns: int an integer, the maximum sum of beauty Constraints • 1sns 1000 • 1sms2000 • 10 s max_t s 100 O s uli]), v[i] sn-1 • uli] * v[i] • 10 s ti] s 100 •Os beauty[i) s 108 • No more than 4 roads connect a single square with others. Two squares can be connected by at most one road. Input Format For Custom Testing Sample Case 0 Sample Input O STDIN Function 4 n = 4 3. m = 3 49 max t = 49 4. n = 4 beauty = [0, 32, 10, 43] 32 10 43 3. m = 3 и [8, 2, 6] 3. m= 3 V= [1, e, 3] You have just arrived in a new city and would like to see its sights. Each sight is located in a square and you have assigned each a beauty value. Each road to a square takes an amount of time to travel, and you have limited time for sightseeing. Determine the maximum value of beauty that you can visit during your time in the city. Start and finish at your hotel, the location of sight zero. Example n = 4 m = 3 %3! max_t = 50 beauty [5, 10, 15, 20] u = [0, 1, 0] v [1, 2, 3] t= [10, 10, 10] • n=4 squares are chosen in the map, including the hotel at square 0. • m= 3 bidirectional roads that connect them Edges are between squares uf] and vfi), and t [] is the time to travel edge i • beauty = (5, 10, 15, 20] represents the beauty values for squares 0, 1, 2, and 3 respectively. • To visit Square 0, 1 and 2 (Starting at the hotel and ending at the hotel), it takes 10 + 10 + 10 + 10 = 40 minutes and it has 5+ 10 + 15 30 beauty value (the beauty value is counted only on your first visit.) • To do a round trip from square 0 to square 3, it hackerrank.com/test/7tb6ldm4ljb/questions/c29hpks40a 20= %3D • To do a round trip from square 0 to square 3, it takes 10 + 10 -20 minutes and it has only 5+ 20%3D 25 beauty value. • The path that gathers squares with the maximum value of beauty that you can visit during max_t= 50 minutes or less, is squares = [0, 1, 2] with 30 as a beauty value. 10 1/10 2/15 10 0/5 10 3/20 Function Description Complete the function findBestPath in the editor below. findBestPath has the following parameter(s): int r. an integer, the number of sights in the city int m. an integer, the number of connecting roads int max t an integer, the amount of time for sightseeing int beauty[n). integer array, the beauty values you have assigned to each sight int u[m) integer array, the starting sight location for each bidirectional road int v[m). integer array, the ending sight location for each bidirectional road int t[m): integer array, the travel time for each bidirectional road Returns: int an integer, the maximum sum of beauty Constraints • 1sns 1000 • 1sms2000 • 10 s max_t s 100 O s uli]), v[i] sn-1 • uli] * v[i] • 10 s ti] s 100 •Os beauty[i) s 108 • No more than 4 roads connect a single square with others. Two squares can be connected by at most one road. Input Format For Custom Testing Sample Case 0 Sample Input O STDIN Function 4 n = 4 3. m = 3 49 max t = 49 4. n = 4 beauty = [0, 32, 10, 43] 32 10 43 3. m = 3 и [8, 2, 6] 3. m= 3 V= [1, e, 3]
Expert Answer:
Answer rating: 100% (QA)
binpython3 import math import os import random import re import sys import heapq Complete ... View the full answer
Related Book For
Posted Date:
Students also viewed these accounting questions
-
The New Jersey teachers union would like to see if there is a difference in the variability of the salaries earned by high school teachers in Cape May County as compared with those in Camden County....
-
You run a small business and would like to predict what will happen to the quantity demanded for your product if you raise your price. While you do not know the exact demand curve for your product,...
-
Your company has some excess cash and would like to invest it in the stock of another company. You investigate several different stocks and are trying to decide which stock companys cash flow. The...
-
In Exercises 7980, find the value of y if the line through the two given points is to have the indicated slope. (3, y) and (1, 4), m = -3
-
As shown in Figure 16.7, the indicator thymol blue has two color changes.Which color change will generally be more suitable for titration of a weak acid with a strong base?
-
How would you answer in the following debate? Q: Isn't it true that the riskiness of a firm's equity will rise if the firm increases its use of debt financing? A: Yes, that's the essence of MM...
-
Calculate the solution to the following mean-reverting rnsteinUhlenbeck SDE: \[d X_{t}=\mu X_{t} d t+\sigma d B_{t}\] with \(X_{0}=x\).
-
Downhill Ski Resort in Colorado has accumulated information from records of the past 30 winters regarding the measurable snowfall. This information is as follows: Snowfall (in.) ...... Frequency 019...
-
In 2019, Rylan Enterprises' net income increased by $2.5 million while its depreciation expense decreased by $500,000, accounts receivable increased by $2,000,000 and accounts payable increased by...
-
For the beam shown in Figure P4-79, use a computer program to determine the deflection at the mid-span using four beam elements, making the shear area zero and then making the shear area equal 5/6...
-
1.What is the probability that the wavefunction is in the ground state|0> or 0(x) 2.What is the probability of measuring the energy as hw/2? (this is not the expectation value) In the quantum...
-
Explain why the plaintiff in Sullivan v. Harnisch was distinguishable from the plaintiff in Weider v. Skala, according to the Court of Appeals of New York
-
Calculate the internal rate of return on this investment An investment project has the following cash flows: _________________________________________________________________________ year 0...
-
what repercussions may the justice system face by keeping a pretrial detainee?
-
The Mitsubishi LandBeast at San Marcos Mitsubishi has a sticker price of $36000. The salesman offers you 0% financing for 72 months on it. If normal loan rates are 5.05%, what should the cash price...
-
How many numbers from 0 to 999 Hint: Think of such numbers as 3-digit strings, with leading 0-s if necessary. Explain briefly are even? are even and have distinct digits? have exactly one digit 9?
-
Topic : BOAT AIRDOPES 131 PRO Technical Communication Professor Jennifer King Purpose The user manual is one of the most familiar examples of technical writing. Its purpose is to provide instructions...
-
The manager of a local convenience store is expanding his line of small toy items. To price these new items, the manager is looking at the prices being charged by competing retailers in his area. For...
-
Suppose that Jones and Smith have each decided to allocate $1000 per year to an entertainment budget in the form of hockey games or rock concerts. They both like hockey games and rock concerts and...
-
From time to time, Congress has raised the minimum wage. Some people suggested that a government subsidy could help employers finance the higher wage. This exercise examines the economics of a...
-
The burden of a tax is shared by producers and consumers. Under what conditions will consumers pay most of the tax? Under what conditions will producers pay most of it? What determines the share of a...
-
Evaluate the shape factor \(\phi_{B}^{f}\) for strength-limited design in bending of a square box section of outer edge-length \(h=100 \mathrm{~mm}\) and wall thickness \(t=3 \mathrm{~mm}\). Is this...
-
Derive the expression for the shape-efficiency factor \(\phi_{B}^{e}\) for stiffness-limited design for a circular tube with outer radius \(5 t\) and wall thickness \(t\), loaded in bending (Fig....
-
Derive the expression for the shape-efficiency factor \(\phi_{B}^{e}\) for stiffness-limited design for a square box section of wall thickness \(t\), and height and width \(h_{1}=10 t\) bent about...
Study smarter with the SolutionInn App