Submission #1000738
Source Code Expand
#pragma comment(linker, "/STACK:512000000")
#define _CRT_SECURE_NO_WARNINGS
//#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve();
void precalc();
clock_t start;
//int timer = 1;
int testNumber = 1;
bool todo = true;
int main() {
#ifdef AIM
freopen("/home/alexandero/ClionProjects/ACM/input.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#else
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
#endif
start = clock();
int t = 1;
cout.sync_with_stdio(0);
cin.tie(0);
precalc();
cout.precision(10);
cout << fixed;
//cin >> t;
int testNum = 1;
while (t--) {
//cerr << testNum << endl;
//cout << "Case #" << testNum++ << ": ";
solve();
++testNumber;
//++timer;
}
#ifdef AIM
cerr << "\n\n time: " << (clock() - start) / 1.0 / CLOCKS_PER_SEC << "\n\n";
#endif
return 0;
}
//BE CAREFUL: IS INT REALLY INT?
template<typename T>
T binpow(T q, T w, T mod) {
if (!w)
return 1 % mod;
if (w & 1)
return q * 1LL * binpow(q, w - 1, mod) % mod;
return binpow(q * 1LL * q % mod, w / 2, mod);
}
template<typename T>
T gcd(T q, T w) {
while (w) {
q %= w;
swap(q, w);
}
return q;
}
template<typename T>
T lcm(T q, T w) {
return q / gcd(q, w) * w;
}
void precalc() {
}
#define int li
const int mod = 1000000007;
void solve() {
int n;
cin >> n;
vector<pair<int, int>> a;
for (int i = 0; i< n; ++i) {
int cur;
cin >> cur;
a.push_back({cur, 0});
}
for (int i = 0; i< n; ++i) {
int cur;
cin >> cur;
a.push_back({cur, 1});
}
sort(all(a));
int res = 1;
vector<int> has(2);
for (int i = (int)a.size() - 1; i >= 0; --i) {
int cur = a[i].second;
if (has[cur ^ 1]) {
res = res * has[cur ^ 1] % mod;
--has[cur ^ 1];
}
else {
++has[cur];
}
}
cout << res << "\n";
}
Submission Info
Submission Time |
|
Task |
A - 1D Matching |
User |
Kostroma |
Language |
C++14 (GCC 5.4.1) |
Score |
500 |
Code Size |
2239 Byte |
Status |
AC |
Exec Time |
48 ms |
Memory |
4464 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 |
29 ms |
2420 KB |
001.txt |
AC |
12 ms |
1400 KB |
002.txt |
AC |
16 ms |
1400 KB |
003.txt |
AC |
18 ms |
2548 KB |
004.txt |
AC |
43 ms |
4464 KB |
005.txt |
AC |
47 ms |
4464 KB |
006.txt |
AC |
48 ms |
4464 KB |
007.txt |
AC |
47 ms |
4464 KB |
008.txt |
AC |
48 ms |
4464 KB |
009.txt |
AC |
47 ms |
4464 KB |
010.txt |
AC |
47 ms |
4464 KB |
011.txt |
AC |
47 ms |
4464 KB |
example0.txt |
AC |
3 ms |
256 KB |
example1.txt |
AC |
3 ms |
256 KB |