Milan Tusk is the richest person in the universe. After devoting decades of his life to further our space exploration technologies, he's finally ready to retire. Being a space enthusiast, the first thing he wants to do is visit n planets p, P2, ..., Pnv in this order. He's currently on planet po. Milan knows that the distance between planets p; and p; , 1 (for o si< n) is d[i] light years. His spaceship uses 1 tonne of fossil fuels per light year. He starts with a full tank and can fill up his tank at any of the n planets (but he must not run out in between two planets). There's a huge cost to set up the spaceship for refuelling. Due to financial constraints (he's not THAT rich), he can fill up his tank at most k times. In order to save money and make his spaceship lighter, Milan is looking for the smallest possible fuel tank that enables him to complete his space travel and reach planet pr. What is the smallest tank capacity that enables him to do so? Filename Your filename for this question must be q3. py. Input The input consists of two lines: • The first line contains n integers separated by single spaces. These numbers specify the list d. • The second line contains a single integer, k. Output Output a single integer: the minimum possible fuel tank capacity (in tonnes) for Milan's spaceship.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

In python

Constraints
• 1sns 100
• osks 100
• 1s d[i] < 100
Time Limit
• Your program has to finish running within 1 second on any valid input.
Sample Input1
2 11
3
Sample Output 1
2
Sample 1 Explanation
• The capacity should be at least 2; Otherwise, Milan can't travel from p, to p,.
• If the capacity is 2, Milan can simply fill up his tank once on p,. Note that
right before he fills up there, his tank is empty, but that's fine because he's
already on p..
Sample Input 2
111 1111
2
Sample Output 2
Transcribed Image Text:Constraints • 1sns 100 • osks 100 • 1s d[i] < 100 Time Limit • Your program has to finish running within 1 second on any valid input. Sample Input1 2 11 3 Sample Output 1 2 Sample 1 Explanation • The capacity should be at least 2; Otherwise, Milan can't travel from p, to p,. • If the capacity is 2, Milan can simply fill up his tank once on p,. Note that right before he fills up there, his tank is empty, but that's fine because he's already on p.. Sample Input 2 111 1111 2 Sample Output 2
Milan Tusk is the richest person in the universe. After devoting decades of his life
to further our space exploration technologies, he's finally ready to retire. Being a
space enthusiast, the first thing he wants to do is visit n planets p, P2, . Pny in
this order. He's currently on planet po-
Milan knows that the distance between planets p; and p; + 1 (for o s i < n) is d[i]
light years. His spaceship uses 1 tonne of fossil fuels per light year. He starts with
a full tank and can fill up his tank at any of the n planets (but he must not run out
in between two planets). There's a huge cost to set up the spaceship for refuelling.
Due to financial constraints (he's not THAT rich), he can fill up his tank at most k
times.
In order to save money and make his spaceship lighter, Milan is looking for the
smallest possible fuel tank that enables him to complete his space travel and
reach planet pr. What is the smallest tank capacity that enables him to do so?
Filename
Your filename for this question must be q3.py.
Input
The input consists of two lines:
• The first line contains n integers separated by single spaces. These numbers
specify the list d.
• The second line contains a single integer, k.
Output
Output a single integer: the minimum possible fuel tank capacity (in tonnes) for
Milan's spaceship.
Transcribed Image Text:Milan Tusk is the richest person in the universe. After devoting decades of his life to further our space exploration technologies, he's finally ready to retire. Being a space enthusiast, the first thing he wants to do is visit n planets p, P2, . Pny in this order. He's currently on planet po- Milan knows that the distance between planets p; and p; + 1 (for o s i < n) is d[i] light years. His spaceship uses 1 tonne of fossil fuels per light year. He starts with a full tank and can fill up his tank at any of the n planets (but he must not run out in between two planets). There's a huge cost to set up the spaceship for refuelling. Due to financial constraints (he's not THAT rich), he can fill up his tank at most k times. In order to save money and make his spaceship lighter, Milan is looking for the smallest possible fuel tank that enables him to complete his space travel and reach planet pr. What is the smallest tank capacity that enables him to do so? Filename Your filename for this question must be q3.py. Input The input consists of two lines: • The first line contains n integers separated by single spaces. These numbers specify the list d. • The second line contains a single integer, k. Output Output a single integer: the minimum possible fuel tank capacity (in tonnes) for Milan's spaceship.
Expert Solution
steps

Step by step

Solved in 5 steps with 2 images

Blurred answer
Knowledge Booster
Dynamic Multithreading
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education