QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 64 MB

#22992. 巻尺を折る

Statistics

透明な巻尺の互いに異なる 6 つの整数位置に、赤 2 個、青 2 個、黄 2 個の印があります。赤い印が重なるように折り、次に折った巻尺を青い印が重なるように折り、最後に黄色い印について同様に折ります。次に処理する 2 つの印がすでに重なっていれば、そのままにします。

折り畳んだ巻尺の長さを求めてください。

入力

最初の行には元の長さ $L$ がセンチメートル単位で与えられ、$10\le L\le1000$ を満たします。

続く 3 行には、赤、青、黄の印の位置がそれぞれ 2 つずつ与えられます。6 つの位置はすべて異なる整数で、巻尺の始点から測った位置です。

出力

最終的な長さを小数点以下ちょうど 1 桁で出力してください。必要なら末尾のゼロも出力します。

入出力例

入力 1

10
2 7
5 4
10 3

出力 1

3.5

注記

巻尺の最初の長さは $10$ cm です。赤い印は $2$ cm と $7$ cm、青い印は $5$ cm と $4$ cm、黄色い印は $10$ cm と $3$ cm にあります。

problem_22992_a50d3f6067b146dfec2d61af0c58d6ff.png

6 つの色付きの印がある元の巻尺

最初は $4.5$ cm の位置で折ります。両側の長さは $4.5$ cm と $5.5$ cm なので、折った巻尺の長さは $5.5$ cm です。青い印はすでに重なっているため、2 回目の折りは省略します。黄色い印が重なるように折ると、長さは $3.5$ cm になります。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.