Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

solve it in c++/java/python add output screenshot also bigbinary-vacations Once upon a time, Oliver was working for BigBinary. BigBinary was so impressed by Oliver's performance

image text in transcribed

image text in transcribed

image text in transcribed

solve it in c++/java/python add output screenshot also

bigbinary-vacations Once upon a time, Oliver was working for BigBinary. BigBinary was so impressed by Oliver's performance that they decided to give him a special task. Oliver was asked to travel among n cities to collect algorithm problems, and he could take vacations in some particular cities and weeks. Oliver was thrilled about this opportunity, but there were certain rules and restrictions that he needed to follow to complete the task successfully. Firstly, Oliver could only travel among n cities, represented by indexes from 0 to n1. He would start from the city indexed 0 on Monday. The cities were connected by flights, and the airline status from city i to city j was represented by an nxn matrix called flights. If there was no flight from the city i to the city j, flights[i][j] would be 0. Otherwise, flights[i][j] would be 1. Also, flights[i][i] would be 0 for all i. Secondly, Oliver had k weeks, each with seven days, to travel. He could only take flights at most once per day, and he could only take flights on each week's Monday morning. Since the flight time was so short, the impact of flight time was not considered in the calculation. Thirdly, for each city, Oliver could only have restricted vacation days in different weeks, given an nk matrix called days, representing this relationship. For the value of days[i][j], it represented the maximum days Oliver could take a vacation in city i in week j. Fourthly, Oliver could stay in a city beyond the number of vacation days, but he should work on the extra days, which would not be counted as vacation days. Moreover, if Oliver flew from city A to city B and took a vacation on that day, the deduction towards vacation days would count towards the vacation days of city B in that week. Lastly, the impact of flight hours was not considered in the calculation of vacation days. Given the two matrices flights and days, Oliver's task was to mat. Lastly, the impact of flight hours was not considered in the un veren calculation of vacation days. Given the two matrices flights and days, Oliver's task was to return the maximum vacation days he could take during k weeks. Oliver needed to come up with a strategy to schedule the traveling to maximize the number of vacation days he could take while following all the rules and restrictions. He had to solve this problem by considering the given matrix of flights and days. Example 1: 0utput: 12 Explanation: Input: n=3,k=3,f1 ights =[[0,1,1],[1,0,1],[1,1,0]], days = Output: 12 One of the best strategies is: 1 st week : fly from city 0 to city 1 on Monday, and play 6 day (Although you start at city 0 , we could also fly to and start 2nd week: fly from city 1 to city 2 on Monday, and play 3 day 3rd week : stay at city 2, and play 3 days and work 4 days. Ans=6+3+3=12. Example 2: 001770017700177 Output: 3 Input: n=3,k=3, flights =[[0,,],[0,,],[0,0,]], days = Explanation: Since there are no flights that enable you to move to another Output: 3 For each week, you only have one day to play and six days to So the maximum number of vacation days is 3 . Ans =1+1+1=3 Example 3: Input: 30117003101070110007 Output: 21 Explanation: Input: n=3,k=3, flights =[[0,1,1],[1,0,1],[1,1,0]], days = Output: 21 One of the best strategies is: 1 st week : stay at city 0 , and play 7 days. 2nd week : fly from city 0 to city 1 on Monday, and play 7 day 3rd week : fly from city 1 to city 2 on Monday, and play 7 das Ans =7+7+7=21 Constraints: - n=f lights. length - n=f lights [i]. length - n== days. length - k== days [i]. length

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

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions