Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
縦 H 行、横 W 列のマス目があり、各マスには 1 つの整数が書かれています。 上から i 行目、左から j 列目のマスに書かれている整数は A_{i, j} です。
マス目が下記の条件を満たすかどうかを判定してください。
1 \leq i_1 < i_2 \leq H および 1 \leq j_1 < j_2 \leq W を満たすすべての整数の組 (i_1, i_2, j_1, j_2) について、A_{i_1, j_1} + A_{i_2, j_2} \leq A_{i_2, j_1} + A_{i_1, j_2} が成り立つ。
制約
- 2 \leq H, W \leq 50
- 1 \leq A_{i, j} \leq 10^9
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
H W A_{1, 1} A_{1, 2} \cdots A_{1, W} A_{2, 1} A_{2, 2} \cdots A_{2, W} \vdots A_{H, 1} A_{H, 2} \cdots A_{H, W}
出力
マス目が問題文中の条件を満たす場合は Yes
と出力し、条件を満たさない場合は No
と出力せよ。
入力例 1
3 3 2 1 4 3 1 3 6 4 1
出力例 1
Yes
1 \leq i_1 < i_2 \leq H および 1 \leq j_1 < j_2 \leq W を満たす整数の組 (i_1, i_2, j_1, j_2) は 9 個存在し、それらすべてについて A_{i_1, j_1} + A_{i_2, j_2} \leq A_{i_2, j_1} + A_{i_1, j_2} が成り立ちます。例えば、
- (i_1, i_2, j_1, j_2) = (1, 2, 1, 2) について、A_{i_1, j_1} + A_{i_2, j_2} = 2 + 1 \leq 3 + 1 = A_{i_2, j_1} + A_{i_1, j_2}
- (i_1, i_2, j_1, j_2) = (1, 2, 1, 3) について、A_{i_1, j_1} + A_{i_2, j_2} = 2 + 3 \leq 3 + 4 = A_{i_2, j_1} + A_{i_1, j_2}
- (i_1, i_2, j_1, j_2) = (1, 2, 2, 3) について、A_{i_1, j_1} + A_{i_2, j_2} = 1 + 3 \leq 1 + 4 = A_{i_2, j_1} + A_{i_1, j_2}
- (i_1, i_2, j_1, j_2) = (1, 3, 1, 2) について、A_{i_1, j_1} + A_{i_2, j_2} = 2 + 4 \leq 6 + 1 = A_{i_2, j_1} + A_{i_1, j_2}
- (i_1, i_2, j_1, j_2) = (1, 3, 1, 3) について、A_{i_1, j_1} + A_{i_2, j_2} = 2 + 1 \leq 6 + 4 = A_{i_2, j_1} + A_{i_1, j_2}
が成り立ちます。残りの (i_1, i_2, j_1, j_2) = (1, 3, 2, 3), (2, 3, 1, 2), (2, 3, 1, 3), (2, 3, 2, 3) についても同様に確認できます。
よって、Yes
を出力します。
入力例 2
2 4 4 3 2 1 5 6 7 8
出力例 2
No
問題文中の条件を満たさないので、No
を出力します。
例えば、(i_1, i_2, j_1, j_2) = (1, 2, 1, 4) について、A_{i_1, j_1} + A_{i_2, j_2} = 4 + 8 > 5 + 1 = A_{i_2, j_1} + A_{i_1, j_2} です。
Score : 200 points
Problem Statement
We have a grid with H horizontal rows and W vertical columns, where each square contains an integer. The integer written on the square at the i-th row from the top and j-th column from the left is A_{i, j}.
Determine whether the grid satisfies the condition below.
A_{i_1, j_1} + A_{i_2, j_2} \leq A_{i_2, j_1} + A_{i_1, j_2} holds for every quadruple of integers (i_1, i_2, j_1, j_2) such that 1 \leq i_1 < i_2 \leq H and 1 \leq j_1 < j_2 \leq W.
Constraints
- 2 \leq H, W \leq 50
- 1 \leq A_{i, j} \leq 10^9
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
H W A_{1, 1} A_{1, 2} \cdots A_{1, W} A_{2, 1} A_{2, 2} \cdots A_{2, W} \vdots A_{H, 1} A_{H, 2} \cdots A_{H, W}
Output
If the grid satisfies the condition in the Problem Statement, print Yes
; otherwise, print No
.
Sample Input 1
3 3 2 1 4 3 1 3 6 4 1
Sample Output 1
Yes
There are nine quadruples of integers (i_1, i_2, j_1, j_2) such that 1 \leq i_1 < i_2 \leq H and 1 \leq j_1 < j_2 \leq W. For all of them, A_{i_1, j_1} + A_{i_2, j_2} \leq A_{i_2, j_1} + A_{i_1, j_2} holds. Some examples follow.
- For (i_1, i_2, j_1, j_2) = (1, 2, 1, 2), we have A_{i_1, j_1} + A_{i_2, j_2} = 2 + 1 \leq 3 + 1 = A_{i_2, j_1} + A_{i_1, j_2}.
- For (i_1, i_2, j_1, j_2) = (1, 2, 1, 3), we have A_{i_1, j_1} + A_{i_2, j_2} = 2 + 3 \leq 3 + 4 = A_{i_2, j_1} + A_{i_1, j_2}.
- For (i_1, i_2, j_1, j_2) = (1, 2, 2, 3), we have A_{i_1, j_1} + A_{i_2, j_2} = 1 + 3 \leq 1 + 4 = A_{i_2, j_1} + A_{i_1, j_2}.
- For (i_1, i_2, j_1, j_2) = (1, 3, 1, 2), we have A_{i_1, j_1} + A_{i_2, j_2} = 2 + 4 \leq 6 + 1 = A_{i_2, j_1} + A_{i_1, j_2}.
- For (i_1, i_2, j_1, j_2) = (1, 3, 1, 3), we have A_{i_1, j_1} + A_{i_2, j_2} = 2 + 1 \leq 6 + 4 = A_{i_2, j_1} + A_{i_1, j_2}.
We can also see that the property holds for the other quadruples: (i_1, i_2, j_1, j_2) = (1, 3, 2, 3), (2, 3, 1, 2), (2, 3, 1, 3), (2, 3, 2, 3).
Thus, we should print Yes
.
Sample Input 2
2 4 4 3 2 1 5 6 7 8
Sample Output 2
No
We should print No
because the condition is not satisfied.
This is because, for example, we have A_{i_1, j_1} + A_{i_2, j_2} = 4 + 8 > 5 + 1 = A_{i_2, j_1} + A_{i_1, j_2} for (i_1, i_2, j_1, j_2) = (1, 2, 1, 4).
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
英小文字と英大文字からなる文字列 S が与えられます。S の長さは奇数です。
S に含まれる大文字の個数が小文字の個数よりも多ければ、S に含まれる全ての小文字を大文字に変換してください。
そうでない場合は、S に含まれる全ての大文字を小文字に変換してください。
制約
- S は英小文字および英大文字からなる文字列
- S の長さは 1 以上 99 以下の奇数
入力
入力は以下の形式で標準入力から与えられる。
S
出力
問題文の指示に従って文字を変換した後の S を出力せよ。
入力例 1
AtCoder
出力例 1
atcoder
AtCoder
に含まれる小文字の個数は 5 個、大文字の個数は 2 個です。よって AtCoder
に含まれる全ての大文字を小文字に変換した atcoder
が答えとなります。
入力例 2
SunTORY
出力例 2
SUNTORY
SunTORY
に含まれる小文字の個数は 2 個、大文字の個数は 5 個です。よって SunTORY
に含まれる全ての小文字を大文字に変換した SUNTORY
が答えとなります。
入力例 3
a
出力例 3
a
Score : 200 points
Problem Statement
You are given a string S consisting of lowercase and uppercase English letters. The length of S is odd.
If the number of uppercase letters in S is greater than the number of lowercase letters, convert all lowercase letters in S to uppercase.
Otherwise, convert all uppercase letters in S to lowercase.
Constraints
- S is a string consisting of lowercase and uppercase English letters.
- The length of S is an odd number between 1 and 99, inclusive.
Input
The input is given from Standard Input in the following format:
S
Output
Print the string S after converting the letters according to the problem statement.
Sample Input 1
AtCoder
Sample Output 1
atcoder
The string AtCoder
contains five lowercase letters and two uppercase letters. Thus, convert all uppercase letters in AtCoder
to lowercase, which results in atcoder
.
Sample Input 2
SunTORY
Sample Output 2
SUNTORY
The string SunTORY
contains two lowercase letters and five uppercase letters. Thus, convert all lowercase letters in SunTORY
to uppercase, which results in SUNTORY
.
Sample Input 3
a
Sample Output 3
a
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 300 点
問題文
1 から N までの番号がついた N 個のドミノがあります。ドミノ i の大きさは S_i です。
いくつかのドミノを左右一列に並べたあとにドミノを倒すことを考えます。ドミノ i が右に向けて倒れる時、ドミノ i のすぐ右に置かれているドミノの大きさが 2 S_i 以下ならばそのドミノも右に向けて倒れます。
あなたは 2 個以上のドミノを選んで左右一列に並べることにしました。ただし、ドミノの並べ方は次の条件を満たす必要があります。
- 一番左のドミノはドミノ 1 である。
- 一番右のドミノはドミノ N である。
- ドミノ 1 のみを右に向けて倒した時に、最終的にドミノ N も右に向けて倒れる。
条件を満たすドミノの並べ方は存在しますか?また、存在する場合は最小で何個のドミノを並べる必要がありますか?
T 個のテストケースが与えられるので、それぞれについて問題を解いてください。
制約
- 1 \leq T \leq 10^5
- 2 \leq N \leq 2 \times 10^5
- 1 \leq S_i \leq 10^9
- 全てのテストケースに対する N の総和は 2 \times 10^5 以下
- 入力される値は全て整数
入力
入力は以下の形式で標準入力から与えられる。ここで \mathrm{case}_i は i 番目のテストケースを意味する。
T \mathrm{case}_1 \mathrm{case}_2 \vdots \mathrm{case}_T
各テストケースは以下の形式で与えられる。
N S_1 S_2 \dots S_N
出力
T 行出力せよ。i 行目には i 番目のテストケースの答えを出力せよ。
各テストケースでは、条件を満たすドミノの並べ方が存在しない場合は -1
を、存在する場合は並べるドミノの最小個数を出力せよ。
入力例 1
3 4 1 3 2 5 2 1 100 10 298077099 766294630 440423914 59187620 725560241 585990757 965580536 623321126 550925214 917827435
出力例 1
4 -1 3
1 番目のテストケースについて、ドミノを左から順にドミノ 1, ドミノ 3, ドミノ 2, ドミノ 4 の順に並べることで問題文の条件を満たすことができます。特に 3 番目の条件については、ドミノ 1 のみを右に向けて倒した時に以下の順にドミノが倒れます。
- ドミノ 1 の右にはドミノ 3 が置かれている。ドミノ 3 の大きさ S_3 = 2 は S_1 \times 2 = 1 \times 2 = 2 以下であるから、ドミノ 3 も右に向けて倒れる。
- ドミノ 3 の右にはドミノ 2 が置かれている。ドミノ 2 の大きさ S_2 = 3 は S_3 \times 2 = 2 \times 2 = 4 以下であるから、ドミノ 2 も右に向けて倒れる。
- ドミノ 2 の右にはドミノ 4 が置かれている。ドミノ 4 の大きさ S_4 = 5 は S_2 \times 2 = 3 \times 2 = 6 以下であるから、ドミノ 4 も右に向けて倒れる。
3 個以下のドミノを並べて問題文の条件を達成することはできないので、答えは 4 個です。
Score : 300 points
Problem Statement
There are N dominoes numbered from 1 to N. The size of domino i is S_i.
Consider arranging some dominoes in a line from left to right and then toppling them. When domino i falls to the right, if the size of the domino placed immediately to the right of domino i is at most 2 S_i, then that domino also falls to the right.
You decided to choose two or more dominoes and arrange them in a line from left to right. The arrangement of dominoes must satisfy the following conditions:
- The leftmost domino is domino 1.
- The rightmost domino is domino N.
- When only domino 1 is toppled to the right, domino N eventually falls to the right as well.
Does an arrangement of dominoes satisfying the conditions exist? If it exists, what is the minimum number of dominoes that need to be arranged?
You are given T test cases, solve the problem for each of them.
Constraints
- 1 \leq T \leq 10^5
- 2 \leq N \leq 2 \times 10^5
- 1 \leq S_i \leq 10^9
- The sum of N over all test cases is at most 2 \times 10^5.
- All input values are integers.
Input
The input is given from Standard Input in the following format, where \mathrm{case}_i means the i-th test case:
T \mathrm{case}_1 \mathrm{case}_2 \vdots \mathrm{case}_T
Each test case is given in the following format:
N S_1 S_2 \dots S_N
Output
Output T lines. The i-th line should contain the answer for the i-th test case.
For each test case, if there is no arrangement of dominoes satisfying the conditions, output -1
; otherwise, output the minimum number of dominoes to arrange.
Sample Input 1
3 4 1 3 2 5 2 1 100 10 298077099 766294630 440423914 59187620 725560241 585990757 965580536 623321126 550925214 917827435
Sample Output 1
4 -1 3
For the 1st test case, arranging the dominoes from left to right in the order domino 1, domino 3, domino 2, domino 4 satisfies the conditions in the problem statement. Specifically, for the 3rd condition, when only domino 1 is toppled to the right, the dominoes fall in the following order:
- Domino 3 is placed to the right of domino 1. Since the size of domino 3, S_3 = 2, is not greater than S_1 \times 2 = 1 \times 2 = 2, domino 3 also falls to the right.
- Domino 2 is placed to the right of domino 3. Since the size of domino 2, S_2 = 3, is not greater than S_3 \times 2 = 2 \times 2 = 4, domino 2 also falls to the right.
- Domino 4 is placed to the right of domino 2. Since the size of domino 4, S_4 = 5, is not greater than S_2 \times 2 = 3 \times 2 = 6, domino 4 also falls to the right.
It is impossible to achieve the conditions in the problem statement by arranging 3 or fewer dominoes, so the answer is 4.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 350 点
問題文
高橋君は医者のすぬけ君から N 種類の薬を処方されました。i 種類目の薬は(処方された日を含めて) a_i 日間、毎日 b_i 錠ずつ飲む必要があります。また、高橋君はこれ以外の薬を飲む必要がありません。
薬を処方された日を 1 日目とします。1 日目以降で、初めて高橋君がその日に飲む必要がある薬が K 錠以下になるのは何日目かを求めてください。
制約
- 1 \leq N \leq 3 \times 10^5
- 0 \leq K \leq 10^9
- 1 \leq a_i,b_i \leq 10^9
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N K a_1 b_1 \vdots a_N b_N
出力
1 日目以降で、初めて高橋君がその日に飲む必要がある薬が K 錠以下になるのが X 日目の時、 X を出力せよ。
入力例 1
4 8 6 3 2 5 1 9 4 2
出力例 1
3
1 日目には、高橋君は 1,2,3,4 種類目の薬をそれぞれ 3,5,9,2 錠飲む必要があります。よってこの日は 19 錠飲む必要があり、K(=8) 錠以下ではありません。
2 日目には、高橋君は 1,2,4 種類目の薬をそれぞれ 3,5,2 錠飲む必要があります。よってこの日は 10 錠飲む必要があり、K(=8) 錠以下ではありません。
3 日目には、高橋君は 1,4 種類目の薬をそれぞれ 3,2 錠飲む必要があります。よってこの日は 5 錠飲む必要があり、初めて K(=8) 錠以下になります。
以上より、3 が答えです。
入力例 2
4 100 6 3 2 5 1 9 4 2
出力例 2
1
入力例 3
15 158260522 877914575 2436426 24979445 61648772 623690081 33933447 476190629 62703497 211047202 71407775 628894325 31963982 822804784 50968417 430302156 82631932 161735902 80895728 923078537 7723857 189330739 10286918 802329211 4539679 303238506 17063340 492686568 73361868 125660016 50287940
出力例 3
492686569
Score : 350 points
Problem Statement
Snuke the doctor prescribed N kinds of medicine for Takahashi. For the next a_i days (including the day of the prescription), he has to take b_i pills of the i-th medicine. He does not have to take any other medicine.
Let the day of the prescription be day 1. On or after day 1, when is the first day on which he has to take K pills or less?
Constraints
- 1 \leq N \leq 3 \times 10^5
- 0 \leq K \leq 10^9
- 1 \leq a_i,b_i \leq 10^9
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N K a_1 b_1 \vdots a_N b_N
Output
If Takahashi has to take K pills or less on day X for the first time on or after day 1, print X.
Sample Input 1
4 8 6 3 2 5 1 9 4 2
Sample Output 1
3
On day 1, he has to take 3,5,9, and 2 pills of the 1-st, 2-nd, 3-rd, and 4-th medicine, respectively. In total, he has to take 19 pills on this day, which is not K(=8) pills or less.
On day 2, he has to take 3,5, and 2 pills of the 1-st, 2-nd, and 4-th medicine, respectively. In total, he has to take 10 pills on this day, which is not K(=8) pills or less.
On day 3, he has to take 3 and 2 pills of the 1-st and 4-th medicine, respectively. In total, he has to take 5 pills on this day, which is K(=8) pills or less for the first time.
Thus, the answer is 3.
Sample Input 2
4 100 6 3 2 5 1 9 4 2
Sample Output 2
1
Sample Input 3
15 158260522 877914575 2436426 24979445 61648772 623690081 33933447 476190629 62703497 211047202 71407775 628894325 31963982 822804784 50968417 430302156 82631932 161735902 80895728 923078537 7723857 189330739 10286918 802329211 4539679 303238506 17063340 492686568 73361868 125660016 50287940
Sample Output 3
492686569
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 350 点
問題文
xy 平面に対し、レーザを照射しながら線分を印字する印字機があります。
- 印字開始時、レーザ照射位置は座標 (0, 0) にある。
-
線分を印字する際は、以下の流れに従う。
- まず、レーザ照射位置を線分の端点のうちどちらか 1 つに移動させる。
- どちらの端点から描画を始めてもよい。
- その後、レーザ照射位置のある端点からもう一方の端点まで、レーザを照射しながらレーザ照射位置を一直線に移動させる。
- 線分の途中で印字を中止することは許されない。
- まず、レーザ照射位置を線分の端点のうちどちらか 1 つに移動させる。
-
レーザを照射していない時、レーザ照射位置は 1 秒あたり速度 S で任意の方向に移動できる。
- レーザを照射している時、レーザ照射位置は 1 秒あたり速度 T で印字中の線分に沿って移動できる。
- レーザ照射位置の移動にかかる時間以外の所要時間は無視できる。
高橋君はこの印字機で N 本の線分を印字したいです。
そのうち i 本目の線分は、座標 (A_i, B_i) と座標 (C_i, D_i) を結びます。
なお、複数の線分が重なっていることがありますが、全ての線分についてその都度重なっている部分を印字する必要があります。
うまく印字機を操作したとき、全ての線分を印字完了するまでにかかる最小の時間は何秒ですか?
制約
- 入力は全て整数
- 1 \le N \le 6
- 1 \le T \le S \le 1000
- -1000 \le A_i,B_i,C_i,D_i \le 1000
- (A_i,B_i) \neq (C_i,D_i) ( 1 \le i \le N )
入力
入力は以下の形式で標準入力から与えられる。
N S T A_1 B_1 C_1 D_1 \vdots A_N B_N C_N D_N
出力
答えを出力せよ。
なお、真の値との絶対誤差または相対誤差が 10^{-6} 以下であれば正解として扱われる。
入力例 1
3 2 1 1 3 2 1 0 2 0 0 3 0 2 0
出力例 1
6.44317475868633722080
- レーザを照射しながらレーザ照射位置を (0,0) から (0,2) まで移動させ、 2 本目の線分を描画する。
- この描画に要する時間は 2 秒である。
- レーザを照射せずレーザ照射位置を (0,2) から (1,3) まで移動させる。
- この移動に要する時間は \sqrt{2}/2 秒である。
- レーザを照射しながらレーザ照射位置を (1,3) から (2,1) まで移動させ、 1 本目の線分を描画する。
- この描画に要する時間は \sqrt{5} 秒である。
- レーザを照射せずレーザ照射位置を (2,1) から (2,0) まで移動させる。
- この移動に要する時間は 1/2 秒である。
-
レーザを照射しながらレーザ照射位置を (2,0) から (3,0) まで移動させ、 3 本目の線分を描画する。
- この描画に要する時間は 1 秒である。
-
全体の所要時間は 2 + (\sqrt{2}/2) + \sqrt{5} + (1/2) + 1\approx 6.443175 秒です。
入力例 2
2 1 1 0 0 10 10 0 2 2 0
出力例 2
20.97056274847714058517
入力例 3
6 3 2 -1000 -1000 1000 1000 1000 -1000 -1000 1000 -1000 -1000 1000 1000 1000 -1000 -1000 1000 1000 1000 -1000 -1000 -1000 1000 1000 -1000
出力例 3
9623.35256169626864153344
複数の線分が重なっていますが、全ての線分についてその都度重なっている部分を印字する必要があります。
入力例 4
6 10 8 1000 1000 -1000 -1000 1000 -1000 -1000 -1000 -1000 1000 1000 1000 -1000 1000 -1000 -1000 1000 1000 1000 -1000 1000 -1000 -1000 1000
出力例 4
2048.52813742385702910909
Score : 350 points
Problem Statement
There is a printing machine that prints line segments on the xy-plane by emitting a laser.
- At the start of printing, the laser position is at coordinate (0, 0).
-
When printing a line segment, the procedure below is followed.
- First, move the laser position to one of the endpoints of the line segment.
- One may start drawing from either endpoint.
- Then, move the laser position in a straight line from the current endpoint to the other endpoint while emitting the laser.
- It is not allowed to stop printing in the middle of a line segment.
- First, move the laser position to one of the endpoints of the line segment.
-
When not emitting the laser, the laser position can move in any direction at a speed of S units per second.
- When emitting the laser, the laser position can move along the line segment being printed at a speed of T units per second.
- The time required for operations other than moving the laser position can be ignored.
Takahashi wants to print N line segments using this printing machine.
The i-th line segment connects coordinates (A_i, B_i) and (C_i, D_i).
Some line segments may overlap, in which case he needs to print the overlapping parts for each line segment separately.
What is the minimum number of seconds required to complete printing all the line segments when he operates the printing machine optimally?
Constraints
- All input values are integers.
- 1 \le N \le 6
- 1 \le T \le S \le 1000
- -1000 \le A_i,B_i,C_i,D_i \le 1000
- (A_i,B_i) \neq (C_i,D_i) ( 1 \le i \le N )
Input
The input is given from Standard Input in the following format:
N S T A_1 B_1 C_1 D_1 \vdots A_N B_N C_N D_N
Output
Print the answer.
Your output will be considered correct if the absolute or relative error from the true value does not exceed 10^{-6}.
Sample Input 1
3 2 1 1 3 2 1 0 2 0 0 3 0 2 0
Sample Output 1
6.44317475868633722080
- Emit the laser while moving the laser position from (0,0) to (0,2), printing the second line segment.
- This takes 2 seconds.
- Move the laser position from (0,2) to (1,3) without emitting the laser.
- This takes \sqrt{2}/2 seconds.
- Emit the laser while moving the laser position from (1,3) to (2,1), printing the first line segment.
- This takes \sqrt{5} seconds.
- Move the laser position from (2,1) to (2,0) without emitting the laser.
- This takes 1/2 second.
- Emit the laser while moving the laser position from (2,0) to (3,0), printing the third line segment.
- This takes 1 second.
- The total time taken is 2 + (\sqrt{2}/2) + \sqrt{5} + (1/2) + 1 \approx 6.443175 seconds.
Sample Input 2
2 1 1 0 0 10 10 0 2 2 0
Sample Output 2
20.97056274847714058517
Sample Input 3
6 3 2 -1000 -1000 1000 1000 1000 -1000 -1000 1000 -1000 -1000 1000 1000 1000 -1000 -1000 1000 1000 1000 -1000 -1000 -1000 1000 1000 -1000
Sample Output 3
9623.35256169626864153344
Multiple line segments overlap here, and you need to print the overlapping parts for each line segment separately.
Sample Input 4
6 10 8 1000 1000 -1000 -1000 1000 -1000 -1000 -1000 -1000 1000 1000 1000 -1000 1000 -1000 -1000 1000 1000 1000 -1000 1000 -1000 -1000 1000
Sample Output 4
2048.52813742385702910909