Submission #4230522
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; using tpl = tuple<int, int, int>; typedef pair<int,int> pii; void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);} int N; int A[100010]; int B[100010]; pii event[200020]; const int mod = 1000000000 + 7; int main(){ cin >> N; for(int i = 0; i < N; i++){ cin >> A[i]; event[i] = pii(A[i], 0); } for(int i = 0; i < N; i++){ cin >> B[i]; event[i + N] = pii(B[i], 1); } ll ans = 1; sort(event, event + 2 * N); int tot_a = 0; for(int i = 0; i < 2 * N; i++){ if(event[i].second == 0){ if(tot_a >= 0) tot_a++; else{ (ans *= abs(tot_a)) %= mod; tot_a++; } } else{ if(tot_a <= 0) tot_a--; else{ (ans *= abs(tot_a)) %= mod; tot_a--; } } } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | ishikado |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 1046 Byte |
Status | AC |
Exec Time | 125 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 | 73 ms | 1664 KB |
001.txt | AC | 28 ms | 768 KB |
002.txt | AC | 38 ms | 1024 KB |
003.txt | AC | 42 ms | 1024 KB |
004.txt | AC | 108 ms | 2304 KB |
005.txt | AC | 123 ms | 2560 KB |
006.txt | AC | 121 ms | 2560 KB |
007.txt | AC | 125 ms | 2560 KB |
008.txt | AC | 121 ms | 2560 KB |
009.txt | AC | 122 ms | 2560 KB |
010.txt | AC | 120 ms | 2560 KB |
011.txt | AC | 123 ms | 2560 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |