Wildcard problem: Existence

0

0 votes
Problem

You are given a 2ntuple of integers (a1,a2,,an,b1,b2,,bn). It is called nice if there exists a constant C such that for any permutation π:{1,2,,n}{1,2,n}, ni=1|aπ(i)bi|=C. Your task is to test if such a tuple is nice.

Input format:
The first line consists of a single integer t, the number of test cases, 0 < t < 11.
The next 3t lines consist of test cases which are as follows:
The first line consists of a single integer n, such that 0 < n < 100001
The second line consists of n space separated integers ai, all between -1 and 1000000001
The third line consists of n space separated integers bi, all between -1 and 1000000001

Output format:
For each test case, in a new line, print "Nice" if the tuple is nice, and "Not nice" if the tuple is not nice, without the quotation marks.

Problem author: Navneel Singhal

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?