CF1827A.Counting Orders
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given two arrays a and b each consisting of n integers. All elements of a are pairwise distinct.
Find the number of ways to reorder a such that ai>bi for all 1≤i≤n , modulo 109+7 .
Two ways of reordering are considered different if the resulting arrays are different.
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t ( 1≤t≤104 ). The description of the test cases follows.
The first line of each test case contains a single integer n ( 1≤n≤2⋅105 ) — the length of the array a and b .
The second line of each test case contains n distinct integers a1 , a2 , … , an ( 1≤ai≤109 ) — the array a . It is guaranteed that all elements of a are pairwise distinct.
The second line of each test case contains n integers b1 , b2 , … , bn ( 1≤bi≤109 ) — the array b .
It is guaranteed that the sum of n over all test cases does not exceed 2⋅105 .
输出格式
For each test case, output the number of ways to reorder array a such that ai>bi for all 1≤i≤n , modulo 109+7 .
输入输出样例
输入#1
5 6 9 6 8 4 5 2 4 1 5 6 3 1 3 4 3 2 3 4 9 1 2 1 3 2 3 4 1 3 3 12 2 3 7 10 23 28 29 50 69 135 420 1000 1 1 2 3 5 8 13 21 34 55 89 144
输出#1
32 0 1 0 13824