Submission #2277425
Source Code Expand
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll mod = 1e9 + 7; int main() { int N; cin >> N; vector<int> a(N), b(N); for (int i = 0; i < N; i++) { cin >> a[i]; } for (int i = 0; i < N; i++) { cin >> b[i]; } sort(a.begin(), a.end()); sort(b.begin(), b.end()); ll res = 1, st = 0; for (int i = 0, j = 0; i < N || j < N; ) { if (i == N) { j++; if (st > 0) res = res * abs(st) % mod; st--; } else if (j == N) { i++; if (st < 0) res = res * abs(st) % mod; st++; } else if (a[i] < b[j]) { i++; if (st < 0) res = res * abs(st) % mod; st++; } else { j++; if (st > 0) res = res * abs(st) % mod; st--; } } cout << res << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | kazuma |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 775 Byte |
Status | AC |
Exec Time | 93 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 | 93 ms | 1024 KB |
009.txt | AC | 93 ms | 1024 KB |
010.txt | AC | 92 ms | 1024 KB |
011.txt | AC | 93 ms | 1024 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |