Submission #3882092
Source Code Expand
#include"bits/stdc++.h" using namespace std; #define int long long #define rep(i,n) for(int i=0;i<n;i++) const long long mod = 1000000007; const int inf = 1145141919; typedef pair<int, int> P; typedef pair<P, int>PP; typedef pair<int, char>PC; struct edge { int to, cost; }; int a[114514], b[114514]; int npr[114514]; signed main() { int n; cin >> n; rep(i, n)cin >> a[i]; rep(i, n)cin >> b[i]; vector<P>V; rep(i, n) { V.push_back(P(a[i], 0)); V.push_back(P(b[i], 1)); } sort(V.begin(), V.end()); npr[0] = 1; rep(i, 112000) { npr[i + 1] = npr[i] * (i + 1); npr[i + 1] %= mod; } int ans = 1; int na = 0, nb = 0; rep(i, n + n) { if (V[i].second) { nb++; if(na)ans *= na*nb; if (na) { na--; nb--; } } else { na++; if(nb)ans *= na*nb; if (nb) { na--; nb--; } } ans %= mod; } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | Rho17 |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 907 Byte |
Status | AC |
Exec Time | 100 ms |
Memory | 7920 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 500 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0.txt, example1.txt |
All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, example0.txt, example1.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
000.txt | AC | 60 ms | 4080 KB |
001.txt | AC | 23 ms | 2292 KB |
002.txt | AC | 31 ms | 2676 KB |
003.txt | AC | 35 ms | 2932 KB |
004.txt | AC | 88 ms | 6128 KB |
005.txt | AC | 99 ms | 6768 KB |
006.txt | AC | 99 ms | 6256 KB |
007.txt | AC | 99 ms | 7024 KB |
008.txt | AC | 99 ms | 6512 KB |
009.txt | AC | 100 ms | 7280 KB |
010.txt | AC | 99 ms | 7920 KB |
011.txt | AC | 99 ms | 7920 KB |
example0.txt | AC | 2 ms | 1152 KB |
example1.txt | AC | 2 ms | 1152 KB |