Contest Duration: ~ (local time)

Submission #2065237

Source Code Expand

Copy
```#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef pair<int,int> pii;

signed main(void) {
int i,j;
int n;
cin>>n;
vector<pii> p(2*n);
rep(i,n){
cin>>p[i].first;
p[i].second=1;
}
rep(i,n){
cin>>p[i+n].first;
p[i+n].second=-1;
}
sort(all(p));
ll ans=1;
int a=0,b=0;
rep(i,2*n){
if(p[i].second==1){//pc
if(a==0)
b++;
else
ans=(ans*a)%MOD,a--;
}else{
if(b==0)
a++;
else
ans=(ans*b)%MOD,b--;
}
}
cout<<ans<<endl;
}
```

#### Submission Info

Submission Time 2018-02-05 00:39:34+0900 A - 1D Matching rika0384 C++14 (GCC 5.4.1) 500 1094 Byte AC 96 ms 3328 KB

#### Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 example0.txt, example1.txt
All 500 / 500 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 58 ms 2176 KB
001.txt 22 ms 896 KB
002.txt 30 ms 1152 KB
003.txt 33 ms 1280 KB
004.txt 86 ms 3072 KB
005.txt 96 ms 3328 KB
006.txt 96 ms 3328 KB
007.txt 96 ms 3328 KB
008.txt 96 ms 3328 KB
009.txt 96 ms 3328 KB
010.txt 95 ms 3328 KB
011.txt 96 ms 3328 KB
example0.txt 1 ms 256 KB
example1.txt 1 ms 256 KB