시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 512 MB | 128 | 80 | 74 | 61.667% |
Have you ever heard of Just Odd Inventions, Ltd.? This company is known for their “just odd inventions.” We call it JOI, Ltd. in this problem. JOI, Ltd. has invented its newest product “Just Long Neckties”. There are N + 1 types of neckties, numbered 1 to N + 1. The length of the i-th necktie (1 ≤ i ≤ N + 1) is Ai.
The company gathered their employees to hold a try-on party. N employees participate in the party, and the j-th employee (1 ≤ j ≤ N) initially wears a necktie of length Bj.
The try-on party is held following this procedure:
If an employee initially wearing a necktie of length b tries a necktie of length a, (s)he feels strangeness of max{a − b, 0}. The oddity of the try-on party is defined as the maximum strangeness among the employees.
We also define Ck as the minimum oddity of the try-on party if CEO of JOI, Ltd. chooses the k-th necktie.
Write a program which, given the lengths of the neckties used at the party and the neckties each employee initially wears, calculates the values of C1,C2, . . . ,CN+1.
Read the following data from the standard input. Given values are all integers.
N A1 . . . AN+1 B1 . . . BN
Write one line to the standard output. The output should contain the values of C1,C2, . . . ,CN+1, separated by a space.
번호 | 배점 | 제한 |
---|---|---|
1 | 1 | N ≤ 10. |
2 | 8 | N ≤ 2000. |
3 | 91 | No additional constraints. |
3 4 3 7 6 2 6 4
2 2 1 1
Here is an example of a try-on party:
In this case, strangeness of each employee is 2, 0, 3 in order. Therefore, the oddity of the party is 3. It is possible to decrease the oddity to 1 if the employees choose different neckties. One of the example is:
In this case, strangeness of each employee is 1, 1, 0 in order. Therefore, the oddity of the party is 1. This is the minimum possible oddity when CEO of JOI, Ltd. chooses the 4th necktie, so C4 = 1.
5 4 7 9 10 11 12 3 5 7 9 11
4 4 3 2 2 2