sdaaaaasdada
2022/3/11 23:14:51
本文主要是介绍sdaaaaasdada,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
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:
- Each test starts with “inflate” first and then “deflate”.
- 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.
|
60 |
[inflate]50 [deflate]40 |
110
60 |
[inflate]20 [deflate]90 |
| |||
-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 |
这篇关于sdaaaaasdada的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2025-01-12百万架构师第十五课:源码分析:Spring 源码分析:SpringMVC核心原理及源码分析|JavaGuide
- 2025-01-11有哪些好用的家政团队管理工具?
- 2025-01-11营销人必看的GTM五个指标
- 2025-01-11办公软件在直播电商前期筹划中的应用与推荐
- 2025-01-11提升组织效率:上级管理者如何优化跨部门任务分配
- 2025-01-11酒店精细化运营背后的协同工具支持
- 2025-01-11跨境电商选品全攻略:工具使用、市场数据与选品策略
- 2025-01-11数据驱动酒店管理:在线工具的核心价值解析
- 2025-01-11cursor试用出现:Too many free trial accounts used on this machine 的解决方法
- 2025-01-11百万架构师第十四课:源码分析:Spring 源码分析:深入分析IOC那些鲜为人知的细节|JavaGuide