Submission #2071490
Source Code Expand
#include<bits/stdc++.h> using namespace std; using Int = long long; //INSERT ABOVE HERE signed main(){ Int n; cin>>n; vector<Int> a(n),b(n); for(Int i=0;i<n;i++) cin>>a[i]; for(Int i=0;i<n;i++) cin>>b[i]; using P = pair<Int, Int>; vector<P> v; for(Int i=0;i<n;i++) v.emplace_back(a[i],0); for(Int i=0;i<n;i++) v.emplace_back(b[i],1); sort(v.begin(),v.end()); Int ans=1; const Int MOD = 1e9+7; Int x=0,y=0; for(Int i=0;i<(Int)v.size();i++){ if(v[i].second==0){ if(y) ans*=y--; else x++; }else{ if(x) ans*=x--; else y++; } ans%=MOD; } cout<<ans<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | beet |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 675 Byte |
Status | AC |
Exec Time | 106 ms |
Memory | 7536 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 | 3316 KB |
001.txt | AC | 22 ms | 1784 KB |
002.txt | AC | 30 ms | 1912 KB |
003.txt | AC | 34 ms | 2932 KB |
004.txt | AC | 88 ms | 6896 KB |
005.txt | AC | 98 ms | 7152 KB |
006.txt | AC | 106 ms | 7024 KB |
007.txt | AC | 98 ms | 7152 KB |
008.txt | AC | 98 ms | 6768 KB |
009.txt | AC | 98 ms | 7536 KB |
010.txt | AC | 98 ms | 7024 KB |
011.txt | AC | 98 ms | 6256 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |