Based on that need help in solving the code for this problem in python. The time complexity has to be as less as possible (nlogn or n at best, no n^2). Apply the divide and conquer algorithm to the problem. Make sure both test cases return correct answers. Output Format For each test case, output a single line, which is the minimum hit points L Leon needs to survive his mission. If Leon needs more than 10^5 HP, print "You're gonna need a flashbang." (without quotes). Sample Input 0 3 1 3 6 4 9 4 3 2 2 Sample Output 0 9 Explanation 0 You only need 9 HP. The scenario runs as follows. There are 3 zombies. Leon can shoot the zombie with 3 HP, downing it. He can still shoot 1 bullet into the zombie with 4 HP, leaving it with 3 HP. Remaining zombies = {3,6} There are 2 zombies that are not downed or stunned, which is not less than Y = 2. Leon guards, taking 1 damage per zombie, for a total of 2 damage. Leon has 7 HP remaining. There are 2 zombies. Leon reloads back to C = 4 bullets in his clip. There are 2 zombies that are not downed or stunned, which is not less than Y = 2. Leon guards, taking 1 damage per zombie, for a total of 2 damage. Leon has 5 HP remaining. There are 2 zombies. Leon can shoot the zombie with 3 HP, downing it. He can still shoot 1 bullet into the zombie with 6 HP, leaving it with 5 HP. Remaining zombies = {5} There is 1 zombie remaining which is not downed or stunned, which is less than Y = 2. Leon charges in, taking 2 damage per zombie, for a total of 2 damage. Leon has 3 HP remaining. Leon has the vaccine. There is 1 zombie. Leon reloads. There is 1 zombie that is not downed or stunned, which is less than Y = 2. Leon charges in, taking 2 damage per zombie, for a total of 2 damage. Leon has 1 HP remaining. Leon escapes the laboratory, succeeding his mission. The actual code # Enter your code here. Read input from STDIN. Print output to STDOUT
Based on that need help in solving the code for this problem in python. The time complexity has to be as less as possible (nlogn or n at best, no n^2). Apply the divide and conquer algorithm to the problem. Make sure both test cases return correct answers. Output Format For each test case, output a single line, which is the minimum hit points L Leon needs to survive his mission. If Leon needs more than 10^5 HP, print "You're gonna need a flashbang." (without quotes). Sample Input 0 3 1 3 6 4 9 4 3 2 2 Sample Output 0 9 Explanation 0 You only need 9 HP. The scenario runs as follows. There are 3 zombies. Leon can shoot the zombie with 3 HP, downing it. He can still shoot 1 bullet into the zombie with 4 HP, leaving it with 3 HP. Remaining zombies = {3,6} There are 2 zombies that are not downed or stunned, which is not less than Y = 2. Leon guards, taking 1 damage per zombie, for a total of 2 damage. Leon has 7 HP remaining. There are 2 zombies. Leon reloads back to C = 4 bullets in his clip. There are 2 zombies that are not downed or stunned, which is not less than Y = 2. Leon guards, taking 1 damage per zombie, for a total of 2 damage. Leon has 5 HP remaining. There are 2 zombies. Leon can shoot the zombie with 3 HP, downing it. He can still shoot 1 bullet into the zombie with 6 HP, leaving it with 5 HP. Remaining zombies = {5} There is 1 zombie remaining which is not downed or stunned, which is less than Y = 2. Leon charges in, taking 2 damage per zombie, for a total of 2 damage. Leon has 3 HP remaining. Leon has the vaccine. There is 1 zombie. Leon reloads. There is 1 zombie that is not downed or stunned, which is less than Y = 2. Leon charges in, taking 2 damage per zombie, for a total of 2 damage. Leon has 1 HP remaining. Leon escapes the laboratory, succeeding his mission. The actual code # Enter your code here. Read input from STDIN. Print output to STDOUT
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
Related questions
Question
Information is present in the screenshot and below. Based on that need help in solving the code for this problem in python. The time complexity has to be as less as possible (nlogn or n at best, no n^2). Apply the divide and conquer
Output Format
For each test case, output a single line, which is the minimum hit points L Leon needs to survive his mission. If Leon needs more than 10^5 HP, print "You're gonna need a flashbang." (without quotes).
Sample Input 0
3 1
3 6 4
9 4 3 2 2
Sample Output 0
9
Explanation 0
You only need 9 HP. The scenario runs as follows.
- There are 3 zombies. Leon can shoot the zombie with 3 HP, downing it. He can still shoot 1 bullet into the zombie with 4 HP, leaving it with 3 HP. Remaining zombies = {3,6}
- There are 2 zombies that are not downed or stunned, which is not less than Y = 2. Leon guards, taking 1 damage per zombie, for a total of 2 damage. Leon has 7 HP remaining.
- There are 2 zombies. Leon reloads back to C = 4 bullets in his clip.
- There are 2 zombies that are not downed or stunned, which is not less than Y = 2. Leon guards, taking 1 damage per zombie, for a total of 2 damage. Leon has 5 HP remaining.
- There are 2 zombies. Leon can shoot the zombie with 3 HP, downing it. He can still shoot 1 bullet into the zombie with 6 HP, leaving it with 5 HP. Remaining zombies = {5}
- There is 1 zombie remaining which is not downed or stunned, which is less than Y = 2. Leon charges in, taking 2 damage per zombie, for a total of 2 damage. Leon has 3 HP remaining. Leon has the vaccine.
- There is 1 zombie. Leon reloads.
- There is 1 zombie that is not downed or stunned, which is less than Y = 2. Leon charges in, taking 2 damage per zombie, for a total of 2 damage. Leon has 1 HP remaining. Leon escapes the laboratory, succeeding his mission.
The actual code
# Enter your code here. Read input from STDIN. Print output to STDOUT |
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
Knowledge Booster
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.Recommended textbooks for you
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education