Submission #1000721


Source Code Expand

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
ll mod=1e9+7;
int N,a[100000],b[100000];
int main(){
	cin>>N;
	rep(i,N) cin>>a[i];
	rep(i,N) cin>>b[i];
	sort(a,a+N);
	sort(b,b+N);
	ll ans=1;
	int j=0;
	rep(i,N-1){
		while(j!=N&&b[j]<a[i]) j++;
		ans=ans*(max(1,j-i))%mod;
	}
	j=0;
	rep(i,N-1){
		while(j!=N&&a[j]<b[i]) j++;
		ans=ans*(max(1,j-i))%mod;
	}
	cout<<ans<<endl;
}

Submission Info

Submission Time
Task A - 1D Matching
User sigma425
Language C++14 (GCC 5.4.1)
Score 500
Code Size 985 Byte
Status AC
Exec Time 107 ms
Memory 1024 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 14
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 65 ms 768 KB
001.txt AC 28 ms 384 KB
002.txt AC 34 ms 512 KB
003.txt AC 38 ms 512 KB
004.txt AC 95 ms 896 KB
005.txt AC 107 ms 1024 KB
006.txt AC 106 ms 1024 KB
007.txt AC 107 ms 1024 KB
008.txt AC 107 ms 1024 KB
009.txt AC 106 ms 1024 KB
010.txt AC 105 ms 1024 KB
011.txt AC 105 ms 1024 KB
example0.txt AC 2 ms 256 KB
example1.txt AC 2 ms 256 KB