ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

sdaaaaasdada

2022-03-11 14:00:26  阅读:418  来源: 互联网

标签:tire deflate air pressure test sdaaaaasdada inflate


Samsung Tire

C/C++/JAVA 3S

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 test s in total.

Each test is constructed of “inflate” and “deflate”.

[inflate]40

[deflate]50

[inflate]60

[deflate]20

[inflate]30

[deflate]40

[inflate]10

[deflate]20

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.

DAMAGED

60

[inflate]50

[deflate]40

                110

60

[inflate]20

[deflate]90

DAMAGED

                -10

Given N, K and N number of test cases, find the test order so that the initial tire air pressure can be minimized.

Print the value of the initial air pressure! (However, if there is no correct answer, print “-1”.)

For instance, suppose there are 3 test cases (N=3) as demonstrated below and the maximum tire air pressure is 100 (K=100).

[inflate]80

[deflate]95

[inflate]45

[deflate]55

[inflate]75

[deflate]30

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”.)

[inflate]45

[deflate]55

[inflate]75

[deflate]30

[inflate]80

[deflate]95

15

                                                95 0                                                        75 45                                                      90 35

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”.

[inflate]90

[deflate]30

[inflate]65

[deflate]20

[Constraints]

1<=N<=8

50<=K<=200

[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 consists of 3 lines.

The 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.)

[In/Output Example]

Input Example

Output Example

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

#1 15

#2 -1

#3 25

#4 -1

#5 45

标签:tire,deflate,air,pressure,test,sdaaaaasdada,inflate
来源: https://blog.csdn.net/zs1235/article/details/123423189

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有