Submission #4070462
Source Code Expand
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; const ll MOD = 1e9+7; pair<int,int> p[200010]; int main(){ ios::sync_with_stdio(false); cin.tie(0); ll ans = 1; int n; cin >> n; for (int i = 0; i < n; i++) { cin >> p[i].first; p[i].second = 1; } for (int i = 0; i < n; i++) { cin >> p[i + n].first; } sort(p,p+2*n); ll ct1 = 0, ct0 = 0; for (int i = 0; i < 2 * n; i++) { if (p[i].second == 0) { if (ct1 == 0) { ct0++; } else { ans *= ct1--; ans %= MOD; } } else { if (ct0 == 0) { ct1++; } else { ans *= ct0--; ans %= MOD; } } } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | xuelei |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 795 Byte |
Status | AC |
Exec Time | 39 ms |
Memory | 1792 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 | 23 ms | 1152 KB |
001.txt | AC | 9 ms | 640 KB |
002.txt | AC | 12 ms | 768 KB |
003.txt | AC | 13 ms | 768 KB |
004.txt | AC | 33 ms | 1664 KB |
005.txt | AC | 37 ms | 1792 KB |
006.txt | AC | 37 ms | 1792 KB |
007.txt | AC | 37 ms | 1792 KB |
008.txt | AC | 39 ms | 1792 KB |
009.txt | AC | 37 ms | 1792 KB |
010.txt | AC | 36 ms | 1792 KB |
011.txt | AC | 37 ms | 1792 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |