Submission #2148215
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;
#define ALL(a) begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define FF first
#define SS second
#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
for(auto& x: xs)
is >> x;
return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
for(unsigned int i=0;i<xs.size();++i)
os << (i?" ":"") << xs[i];
return os;
}
template<class T>
void maxi(T& x, T y){
if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
if(x > y) x = y;
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
const LL MOD = 1e9+7;
int main(){
cin.tie(0);
ios_base::sync_with_stdio(false);
LL N;
cin >> N;
vector<PLL> xs(N*2);
REP(i,N){
cin >> xs[i].FF;
xs[i].SS = -1;
}
REP(i,N){
cin >> xs[N+i].FF;
xs[N+i].SS = 1;
}
SORT(xs);
LL num = 0, ans = 1;
for(auto& p: xs){
if(!num) num += p.SS;
else{
if(p.SS * num < 0)
(ans *= abs(num)) %= MOD;
num += p.SS;
}
}
cout << ans << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
A - 1D Matching |
User |
okaduki |
Language |
C++14 (GCC 5.4.1) |
Score |
500 |
Code Size |
1884 Byte |
Status |
AC |
Exec Time |
37 ms |
Memory |
3456 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 |
23 ms |
2176 KB |
001.txt |
AC |
9 ms |
896 KB |
002.txt |
AC |
12 ms |
1280 KB |
003.txt |
AC |
13 ms |
1280 KB |
004.txt |
AC |
33 ms |
3072 KB |
005.txt |
AC |
37 ms |
3456 KB |
006.txt |
AC |
37 ms |
3456 KB |
007.txt |
AC |
37 ms |
3328 KB |
008.txt |
AC |
37 ms |
3456 KB |
009.txt |
AC |
37 ms |
3456 KB |
010.txt |
AC |
37 ms |
3328 KB |
011.txt |
AC |
36 ms |
3328 KB |
example0.txt |
AC |
1 ms |
256 KB |
example1.txt |
AC |
1 ms |
256 KB |