Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int Mod = 1e9 + 7;
- int main() {
- ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
- int testcase;
- cin >> testcase;
- while(testcase--) {
- int n;
- cin >> n;
- vector <int> a, b;
- for (int i = 0; i < n; i++) {
- int x;
- cin >> x;
- a.push_back(x);
- }
- for (int i = 0; i < n; i++) {
- int x;
- cin >> x;
- b.push_back(x);
- }
- sort(a.begin(), a.end());
- sort(b.rbegin(), b.rend());
- long long int ans = 1;
- for (int i = 0; i < n; i++) {
- int it = upper_bound(a.begin(), a.end(), b[i]) - a.begin();
- if (it == n) ans *= 0;
- ans *= (n - it - i);
- ans %= Mod;
- }
- cout << ans << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement