2540: 【vector】The Intervals

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:23 解决:13

题目描述

Cantor, the famous mathematician, was working on a problem about intervals.

Let's start from a line segment of unit length. Remove its middle 1/3. 

Now remove the middle 1/3's from the remaining two segments.
Now remove the middle 1/3's from the remaining four segments.
Now remove the middle 1/3's from the remaining eight segments.
Now remove ... well, you get the idea.

If you could continue this procedure through infinitely many steps, what would you have left?

Now he assigns the following task to you. (He asked me to pass his assignment to you last night.)

Given two arrays of numbers {A(n)} and {B(m)}. For each B(i) in {B(m)}, find 2 numbers a and b from {A(n)}, such that B(i) is in [a,b) and b-a<=|b'-a'| for all a' and b' from {A(n)} such that [a',b') contains B(i).

输入

There are several test cases. 

In each test case, the first line gives n and m.

The second line contains n numbers, which are the elements of {A(n)}.

The third line contains m nubmers, which are the elements of {B(m)}.

输出

For each B(i) in {B(m)}, output a line containing the interval [a,b). 

If there is no such interval, output "no such interval" instead.

Print a blank line after each test case.

样例输入 复制

3 3
10 20 30
15 25 35

样例输出 复制

[10,20)
[20,30)
no such interval