The Whim of Mr Doraemon
All submissions for this problem are available.
Not long after their country lifted the World Cup, the people of Nobitaville decided to organize a Victory Marathon for celebrations. While other preparations were in order, Mr.Doraemon, who happened to be a very moody person, made it clear by announcing that he would let the Marathon take place only if Jerseys were distributed among people in some sort of order. He added that the richest person should get the smallest Jersey Number and the next richest person, the second smallest jersey number, and so on and so forth. If this order would be taken care of, the mayor would happily let the people enjoy the Marathon, else everybody would be sent back home. The people are really looking forward to enjoy the Marathon but are quite worried about this wish of the mayor and hence, need your help. Jerseys have already been distributed among the people. You need to check whether the Marathon will take place or not, so that if not, the people can reshuffle the jerseys and fulfill the mayor's wish.
The first line of Input contains an integer T, denoting the number of test cases.
Then T test cases follow.
The first line of each test case contains an integer N, denoting the number of people participating in the Marathon. This is followed by two lines, each containing N number of entries. The first line contains N distinct numbers, denoting the Jersey Number of the people( Ai ). The second line contains N numbers, denoting the wealth of the people( Bi ), with ith wealth corresponding to the ith person, mentioned in the previous line.
If the Jerseys have been distributed in the order the Mayor demands, print "YES" and if not, print "NO" (without quotes).
- 1 ≤ T ≤ 100
- 1 ≤ N ≤ 10^5
- 1 ≤ Ai ≤ 10^9
- 1 ≤ Bi ≤ 10^9
Input: 2 5 2 3 5 1 4 600 400 100 2000 250 4 7 9 11 12 6000 7000 4000 102 Output: YES NO
NOTE: Jersey Numbers will not be provided in non-decreasing fashion.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions