Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Help me to solve this question in Python. Sample input: 5 3 100 75 45 80 30 55 95 2 100 65 90 20 30
Help me to solve this question in Python.
Sample input:
5 3 100 75 45 80 30 55 95 2 100 65 90 20 30 5 150 35 105 100 45 75 115 75 55 35 105 7 150 70 95 15 65 85 75 55 105 80 10 90 115 110 45 8 200 35 30 50 80 70 15 10 40 70 20 20 85 65 40 25 50
Sample Output:
#1 15 #2 -1 #3 25 #4 -1 #5 45
Starting code:
import sys sys.stdin = open("input.txt", "r")
T = int(input()) for test_case in range(1, T + 1):
# Solution will be in here!!!!
Samsung tire is before its launch. Prior to its product launch, it will test the safety of the tire. In order to launch the tire, the tire must pass N tests in total. Each test is constructed of "inflate" and "deflate" \begin{tabular}{|c} \hline [inflate] \\ 40 \\ [deflate] \\ 50 \\ \hline \end{tabular} and has the following features: (1) Each test starts with "inflate" first and then "deflate". (2) As long as all N test cases are executed, the test order can be randomly chosen. The maximum air pressure of the Samsung tire is K. The tire gets damaged, if the inner air pressure of the tire exceeds K or is less than 0. For instance, given the maximum tire air pressure K=100 and the initial air pressure as 60 , the tire in the following two cases will get damaged. For instance, suppose there are 3 test cases (N=3) as demonstrated below and the maximum tire air pressure is 100(K=100). \begin{tabular}{|c|c|} \hline [inflate] & [inflate] \\ 75 & 80 \\ {[ deflate] } & [deflate] \\ 30 & 95 \\ \hline \end{tabular} The order of testing so that the initial tire air pressure can be minimized is shown below which is 15 in this case. (The blue numbers denote the air pressure after either "inflate" or "deflate") Below is an example of tire damage, independent of the initial air pressure and the order of testing. (N=2,K=100) The answer is " 1" ". [Constraints] 1N850K200 [Input] The first line contains a single integer T-the number of total test cases. From the next line on each test case is given. Each test case consist of 3 linesthe first line contains N,K, the second line contains the "inflate" value for each test case and the third line contains the "deflate" value for each test case. [Output] Print "\#t" (without the quotes), leave a blank space and print the answer. (t refers to the test case number and starts with 1)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started