Submission #1203903


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
vector<pair<int,int>> V;
ll mo=1000000007;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>x, V.push_back({x,0});
	FOR(i,N) cin>>x, V.push_back({x,1});
	sort(ALL(V));
	
	ll ret = 1;
	x = 0;
	FORR(r,V) {
		if(r.second==0) {
			if(x<0) ret = (ret*(-x))%mo;
			x++;
		}
		else {
			if(x>0) ret = (ret*x)%mo;
			x--;
		}
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}

Submission Info

Submission Time
Task A - 1D Matching
User kmjp
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1080 Byte
Status AC
Exec Time 40 ms
Memory 2420 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 24 ms 1400 KB
001.txt AC 9 ms 892 KB
002.txt AC 12 ms 892 KB
003.txt AC 14 ms 1400 KB
004.txt AC 36 ms 2420 KB
005.txt AC 40 ms 2420 KB
006.txt AC 40 ms 2420 KB
007.txt AC 39 ms 2420 KB
008.txt AC 40 ms 2420 KB
009.txt AC 40 ms 2420 KB
010.txt AC 39 ms 2420 KB
011.txt AC 40 ms 2420 KB
example0.txt AC 1 ms 256 KB
example1.txt AC 1 ms 256 KB