Submission #2233249


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, MOD = 1e9 + 7;
vector<pair<int, int>> v;

int main() {
	cin >> n;
	inc(i, 2 * n) { int a; cin >> a; v.EB(a, (i < n ? +1 : -1)); }
	
	sort(ALL(v));
	
	LL ans = 1, c = 0;
	inc(i, 2 * n) {
		if(abs(c + v[i].SE) < abs(c)) { (ans *= abs(c)) %= MOD; }
		c += v[i].SE;
	}
	
	cout << ans << endl;
	
	return 0;
}

Submission Info

Submission Time
Task A - 1D Matching
User FF256grhy
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1893 Byte
Status AC
Exec Time 125 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 74 ms 1400 KB
001.txt AC 28 ms 892 KB
002.txt AC 40 ms 892 KB
003.txt AC 43 ms 1400 KB
004.txt AC 110 ms 2420 KB
005.txt AC 125 ms 2420 KB
006.txt AC 123 ms 2420 KB
007.txt AC 125 ms 2420 KB
008.txt AC 123 ms 2420 KB
009.txt AC 125 ms 2420 KB
010.txt AC 122 ms 2420 KB
011.txt AC 124 ms 2420 KB
example0.txt AC 1 ms 256 KB
example1.txt AC 1 ms 256 KB