Submission #2630361
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
int n;
P a[1000000];
ll va,vb;
ll ans=1;
int main(){
cin>>n;
rep(i,n){
int b;
cin>>b;
a[i] = P(b,0);
}
rep(i,n){
int b;
cin>>b;
a[n+i] = P(b,1);
}
sort(a,a+2*n);
rep(i,2*n){
if(a[i].second==0){
if(!vb) va++;
else{
ans *= vb;
ans %= M;
vb--;
}
}
else{
if(!va) vb++;
else{
ans *= va;
ans %= M;
va--;
}
}
}
cout<<ans<<endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
A - 1D Matching |
User |
mint |
Language |
C++14 (GCC 5.4.1) |
Score |
500 |
Code Size |
988 Byte |
Status |
AC |
Exec Time |
122 ms |
Memory |
1792 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 |
107 ms |
1664 KB |
005.txt |
AC |
122 ms |
1792 KB |
006.txt |
AC |
120 ms |
1792 KB |
007.txt |
AC |
122 ms |
1792 KB |
008.txt |
AC |
120 ms |
1792 KB |
009.txt |
AC |
122 ms |
1792 KB |
010.txt |
AC |
119 ms |
1792 KB |
011.txt |
AC |
122 ms |
1792 KB |
example0.txt |
AC |
1 ms |
256 KB |
example1.txt |
AC |
1 ms |
256 KB |