-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA.cpp
More file actions
38 lines (34 loc) · 669 Bytes
/
A.cpp
File metadata and controls
38 lines (34 loc) · 669 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <bits/stdc++.h>
using namespace std;
void solve()
{
int n;
cin >> n;
long long int A[n],B[n];
for(int i=0;i<n;i++)
cin >> A[i];
for(int i=0;i<n;i++)
cin >> B[i];
sort(A,A+n,greater<int>());
sort(B,B+n,greater<int>());
int A_in, B_in;
A_in=0;
long long int prod = 1;
for(B_in=0;B_in<n;B_in++){
for(;A_in<n;A_in++){
if(B[B_in]>=A[A_in])
break;
}
prod = (prod*(A_in-B_in))%int(1e9+7);
}
cout << prod%int(1e9+7) << endl;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--)
solve();
}