编程介的小学生 2019-09-02 10:57 采纳率: 20.5%
浏览 82

The skatepark's new ramps 程序编写

Problem Description
The local skating park has been given a nancial incentive by the city to make the park interesting for skaters of all levels. The park wants to use the incentive to build a series of ramps, somewhat resembling a mountain range. When talking to some of the volunteers in the committee responsible for the project, you find out they're having diffculties deciding about the best con guration of the ramps. They know the number of ramps to be built, and for each ramp they agree on the range of the height for that ramp. They are still discussing exactly how high each ramp should be, since they can't a ord to have them all at their highest, but they do want to spend all of the budget. This is the most important issue in the debate: they can't agree whether they want the di erences between the ramps to be small, to give the full ride a more consistent feeling, or as big as possible, to create a more diverse set of challenges.

You also notice they don't really have a good idea what the possibilities are, leaving them stranded in 'what-if' discussions. You decide to help them out by showing them the options they have, both the ones where the di erence between the highest and lowest ramp is kept as small as possible, as well as the one where that di erence is as much as possible. Since the committee is mainly bickering over the allowable di erences, you decide to start out by just presenting them the minimum and maximum di erence-between the highest and lowest ramp. Luckily, the park has a lot of space, so you won't need to take the placement of the ramps into account. All ramps
have the same inclination, which is such that a ramp of height h will have a length 4h (measured at, not over the ramp).

Input
The rst line of input consists of the integer number n, the number of test cases;
Then, for each test case:
A line with the integer number r (2 <=r<=10000), the number of ramps the park will place;
A line with the integer number m (0 <= m <=200000000 = 2*10^8), the number of cubic meters of concrete the park has money for;
r lines with two numbers, l and t (0.00 <=l <=t <= 100.00), separated by one space, the minimum and maximum height in meters of the r-th ramp.

You may assume all ramps are made entirely of concrete, and shaped as 1 meter wide prisms, with a triangle with two equal sides as base. A series of ramps within the given constraints and using all concrete is guaranteed to exist.

Output
For each test case, the output contains one line with two numbers, separated by one space: the minimum difference between the highest and lowest ramp and the maximum difference between the highest and the lowest ramp. These numbers are rounded to two decimals.

Sample Input
1
3
36
1.00 4.00
1.00 4.00
1.00 4.00

Sample Output
0.00 3.00

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥50 易语言把MYSQL数据库中的数据添加至组合框
    • ¥20 求数据集和代码#有偿答复
    • ¥15 关于下拉菜单选项关联的问题
    • ¥20 java-OJ-健康体检
    • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
    • ¥15 使用phpstudy在云服务器上搭建个人网站
    • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
    • ¥15 vue3+express部署到nginx
    • ¥20 搭建pt1000三线制高精度测温电路
    • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况