問題一覧 > 通常問題

No.2010 Magical Floor

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 小数誤差許容問題 絶対誤差または相対誤差が $10^{-8}$ 以下。ただし、ジャッジ側の都合で500桁未満にしてください
タグ : (AC するまで非表示) / 解いたユーザー数 22
作問者 : Kiri8128 / テスター : tarattata1
お気に入りにしたユーザー ProblemId : 5554 / 自分の提出
問題文最終更新日: 2022-05-07 02:01:54
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 352 (順位表) の他の問題:

Problem Statement

There are $N$ magical floors on the $xy$-plane, and the $i$-th ($1 \le i \le N$) magical floor occupies the range $H_{i-1} \le y < H_{i}$. Here, $0 = H_0 < H_1 < \cdots < H_N = H$ holds. The speed of movement on this plane depends on the location: on the $i$-th magical floor, it takes time $A_i$ to travel a distance of $1$. You want to move from $(0,\ 0)$ to $(X,\ 0)$ through the part of this plane with $0 \le y < H$. Find the minimum time required for the move.
Answer $T$ test cases.

Input

First, the number of test cases $T$ is given on $1$ line. $T$ is an integer satisfying $1 \le T \le 100$.
$T$

The following $3T$ lines give the information of each test case.
The information of each test case is given in every $3$ lines, in the following format.
$N\ X$
$H_1\ H_2\ \cdots \ H_N$
$A_1\ A_2\ \cdots \ A_N$

(Constraints)
All inputs are integers
$1 \le N \le 100$
$1 \le X \le 10^9$
$0 < H_1 < H_2 < \cdots < H_N \le 10^9$
$0 \le A_i \le 10^9$

Output

Output the minimum time required to move from $(0,\ 0)$ to $(X,\ 0)$.
Print a newline at the end.
Your answer is considered correct if its absolute or relative error from the correct answer is at most $10^{-8}$.
It can be proved that the minimum value always exists under the constraints of this problem.

Sample

Sample 1
Input
3
2 2
1 2
2 1
2 5
2 3
1 0
2 4
1 2
2 1
Output
4
4
7.464101615137754

This sample has $3$ test cases.

In the $1$st test case, going straight from $(0,\ 0)$ to $(2,\ 0)$ takes time $4$. It is impossible to arrive in less time, so output $4$.

In the $2$nd test case, going straight from $(0,\ 0)$ to $(5,\ 0)$ takes time $5$, but moving in the order $(0,\ 0)$ → $(0,\ 2)$ → $(5,\ 2)$ → $(5,\ 0)$ lets you arrive in time $4$. On the $2$nd magical floor, no time is required no matter how far you move.

In the $3$rd test case, going straight from $(0,\ 0)$ to $(4,\ 0)$ takes time $8$, but by making good use of the $2$nd magical floor, you can arrive slightly sooner. Your answer is considered correct if its absolute or relative error from the correct answer is at most $10^{-8}$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。