-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1827A.cpp
More file actions
40 lines (34 loc) · 789 Bytes
/
1827A.cpp
File metadata and controls
40 lines (34 loc) · 789 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
39
40
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
vector<ll> a(n), b(n);
for (ll &x : a) cin >> x;
for (ll &x : b) cin >> x;
sort(a.begin(), a.end());
sort(b.begin(), b.end());
ll comb = 1;
int j = n - 1;
for (int i = n - 1; i >= 0; i--) {
while (j >= 0 && a[j] > b[i]) j--;
int valid = n - j - 1 - (n - 1 - i);
if (valid <= 0) {
comb = 0;
break;
}
comb *= valid;
comb=comb%1000000007;
}
cout << comb << '\n';
}
return 0;
}