Submission #4080149
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> pll; #define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i)) #define REP(i, n) FOR(i, n, 0) #define OF64 std::setprecision(10) const ll MOD = 1000000007; const ll INF = (ll)1e15; ll A[100005]; ll B[100005]; ll T[100005]; int main() { int N; cin >> N; REP(i, N) { cin >> A[i]; } REP(i, N) { cin >> B[i]; } //! n!%MOD T[0] = 1; FOR(i, N + 1, 1) { T[i] = T[i - 1] * i; T[i] %= MOD; } sort(A, A + N); sort(B, B + N); A[N] = INF; B[N] = INF; ll sum = 1; int pi = 0, wi = 0; int np = 0, nw = 0; while (pi < N || wi < N) { if (A[pi] < B[wi]) { pi++; if (nw > np) { sum *= nw; nw--; } else { np++; } } else { wi++; if (np > nw) { sum *= np; np--; } else { nw++; } } sum %= MOD; } cout << sum << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | coco18000 |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 1340 Byte |
Status | AC |
Exec Time | 93 ms |
Memory | 2560 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 | 57 ms | 1664 KB |
001.txt | AC | 21 ms | 768 KB |
002.txt | AC | 29 ms | 1024 KB |
003.txt | AC | 32 ms | 1024 KB |
004.txt | AC | 83 ms | 2304 KB |
005.txt | AC | 93 ms | 2560 KB |
006.txt | AC | 93 ms | 2560 KB |
007.txt | AC | 93 ms | 2560 KB |
008.txt | AC | 93 ms | 2560 KB |
009.txt | AC | 93 ms | 2560 KB |
010.txt | AC | 93 ms | 2560 KB |
011.txt | AC | 93 ms | 2560 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |