Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python solution to the following algorithm question: 'Aerial Movie'. In order to prevent passengers from being too bored during the flight, LQ Airlines decided to

Python solution to the following algorithm question: 'Aerial Movie'.

In order to prevent passengers from being too bored during the flight, LQ Airlines decided to play two movies during the flight. Since the movie cannot be played during the take-off and landing of the aircraft, LQ Airlines must ensure that the duration of the two movies to be less than or equal to the flight duration minus 30 minutes, and the total length of the two movies should be as long as possible. Now given t ,the flight duration(minutes), and array dur[],the length of movies. Please output the length of the two movies in order of length. If there are multiple groups of the same length, select the one which contains the longest single movie.It is guarantee that there is a least one solution.

Example

Given t=87,dur=[20,25,19,37],return[20,37]

Explanation: 87-30=57 20+25=45,57-45=12 20+19=39,57-39=19 20+37=57,57-57=0 25+19=44,57-44=13 25+37=62,57<62 19+37=56,57-56=1 

Givent=67,dur=[20,17,19,18],return[17,20]

Explanation: 67-30=37 17+20=37,18+19=37 The longest movie in the first group is 20and 19 in the second grouo, so output`[17,20]`

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

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

ISBN: 0132742926, 978-0132742924

More Books

Students also viewed these Databases questions