Submission #1000582
Source Code Expand
#include <string> #include <vector> #include <cstdio> #include <cstdlib> #include <cmath> #include <algorithm> #include <queue> #include <map> #include <set> #include <iostream> #include <sstream> #include <cstring> #include <numeric> using namespace std; typedef long long ll; typedef pair<int,int> pii; #define F0(i,n) for (int i = 0; i < n; i++) #define F1(i,n) for (int i = 1; i <= n; i++) #define CL(a,x) memset(x, a, sizeof(x)); #define SZ(x) ((int)x.size()) const double eps = 1e-10; const int MOD = 1000000007; int i, j, k, m, n, l; ll ans; int main() { //freopen("x.in", "r", stdin); cin >> n; vector<pii> v; F0(i, n) { cin >> j; v.push_back(pii(j, -1)); } F0(i, n) { cin >> j; v.push_back(pii(j, 1)); } sort(v.begin(), v.end()); ans = 1; int b = 0; for (pii p : v) { if (p.second == 1) { if (b >= 0) b++; else { ans = ans * abs(b) % MOD; b++; } } else { if (b <= 0) b--; else { ans = ans * abs(b) % MOD; b--; } } } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | USA |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 1074 Byte |
Status | AC |
Exec Time | 101 ms |
Memory | 2420 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 | 62 ms | 1400 KB |
001.txt | AC | 24 ms | 892 KB |
002.txt | AC | 32 ms | 892 KB |
003.txt | AC | 36 ms | 1400 KB |
004.txt | AC | 90 ms | 2420 KB |
005.txt | AC | 101 ms | 2420 KB |
006.txt | AC | 100 ms | 2420 KB |
007.txt | AC | 100 ms | 2420 KB |
008.txt | AC | 100 ms | 2420 KB |
009.txt | AC | 100 ms | 2420 KB |
010.txt | AC | 100 ms | 2420 KB |
011.txt | AC | 100 ms | 2420 KB |
example0.txt | AC | 3 ms | 256 KB |
example1.txt | AC | 3 ms | 256 KB |