Submission #2119148
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define rep(i,n) FOR(i,0,n) #define pb emplace_back typedef long long ll; typedef pair<int,int> pint; pint p[200001]; vector<int> v0,v1; const int mod=1000000007; int main(){ int n,m,ai; cin>>n; rep(i,n){ cin>>ai; p[i]={ai,0}; } rep(i,n){ cin>>ai; p[i+n]={ai,1}; } sort(p,p+n+n); ll mul=1; rep(i,n+n){ if(p[i].second==0){ if(!v1.empty()){ mul*=v1.size();v1.pop_back(); mul%=mod; } else v0.pb(i); } else{ if(!v0.empty()){ mul*=v0.size();v0.pop_back(); mul%=mod; } else v1.pb(i); } } cout<<mul<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | ts_ |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 893 Byte |
Status | AC |
Exec Time | 123 ms |
Memory | 2428 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 | 1152 KB |
001.txt | AC | 27 ms | 640 KB |
002.txt | AC | 37 ms | 768 KB |
003.txt | AC | 42 ms | 768 KB |
004.txt | AC | 109 ms | 1664 KB |
005.txt | AC | 120 ms | 1792 KB |
006.txt | AC | 122 ms | 1792 KB |
007.txt | AC | 123 ms | 1792 KB |
008.txt | AC | 123 ms | 1792 KB |
009.txt | AC | 120 ms | 1792 KB |
010.txt | AC | 122 ms | 2428 KB |
011.txt | AC | 120 ms | 1792 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |