Submission #2702173
Source Code Expand
// finish date: 2018/06/17 #include <iostream> #include <cmath> #include <vector> #include <bitset> #include <algorithm> #include <stack> #include <queue> #include <map> #include <climits> #include <functional> using namespace std; #define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++) #define rep(i, n) FOR(i,0,n) #define ll long long #define vi vector<int> #define vvi vector<vector<int>> #define vvvi vector<vector<vector<int>>> #define vl vector<ll> #define vvl vector<vector<ll>> #define vd vector<double> #define vvd vector<vector<double>> #define vb vector<bool> #define vvb vector<vector<bool>> #define vs vector<string> #define vc vector<char> #define vvc vector<vector<char>> #define pii pair<int,int> const int bigmod = 1000000007; #define INF 1050000000 //掛け算 int mul(int a, int b) { return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod); } int main() { int N; cin >> N; vi a(N + 1), b(N + 1); rep(i, N) { cin >> a[i]; } rep(i, N) { cin >> b[i]; } a[N] = INF; b[N] = INF; sort(a.begin(), a.end()); sort(b.begin(), b.end()); int g = 0; int h = 0; int ans = 1; int stock = 0; while (g < N || h < N) { if (a[g] < b[h]) { if (stock < 0) ans = mul(ans, -stock); stock++; g++; } else { if (stock > 0) ans = mul(ans, stock); stock--; h++; } } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | TASSAN |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 1569 Byte |
Status | AC |
Exec Time | 94 ms |
Memory | 1024 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 | 56 ms | 768 KB |
001.txt | AC | 21 ms | 384 KB |
002.txt | AC | 29 ms | 512 KB |
003.txt | AC | 32 ms | 512 KB |
004.txt | AC | 83 ms | 896 KB |
005.txt | AC | 93 ms | 1024 KB |
006.txt | AC | 93 ms | 1024 KB |
007.txt | AC | 93 ms | 1024 KB |
008.txt | AC | 94 ms | 1024 KB |
009.txt | AC | 93 ms | 1024 KB |
010.txt | AC | 93 ms | 1024 KB |
011.txt | AC | 93 ms | 1024 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |