CF1827A.Counting Orders
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
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.
给你两个长度均为 n 的整数数组 a 和 b。数组 a 中的所有元素两两互不相同。
求将 a 重新排列,使得对所有 1≤i≤n 均满足 ai>bi 的方案数,结果对 109+7 取模。
若两种重排方式得到的数组不同,则认为它们是不同的方案。
输入格式
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.
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤104)。随后是各测试用例的描述。
每个测试用例的第一行包含一个整数 n(1≤n≤2⋅105)—— 数组 a 和 b 的长度。
每个测试用例的第二行包含 n 个互不相同的整数 a1, a2, …, an(1≤ai≤109)—— 数组 a。保证数组 a 中所有元素两两不同。
每个测试用例的第三行包含 n 个整数 b1, b2, …, bn(1≤bi≤109)—— 数组 b。
保证所有测试用例的 n 值之和不超过 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.
对于每个测试用例,输出将数组 a 重新排列的方式数目,使得对所有 1≤i≤n 均满足 ai>bi,结果对 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
输入解题思路,AI测评打分。不知道怎么写?