Submission #1678296
Source Code Expand
#include<iostream> #include<vector> #include<algorithm> using namespace std; using lli = long long int; int main(){ int n; std::cin >> n; vector<int> a(n), b(n); for (int i = 0; i < n; i++) std::cin >> a[i]; for (int i = 0; i < n; i++) std::cin >> b[i]; sort(a.begin(), a.end()); sort(b.begin(), b.end()); lli ans = 1, mod = 1e9 + 7; for (int i = 0; i < n; i++) { int pos, prev; if(a[i] < b[i]){ pos = *lower_bound(b.begin() + i, b.end(), a[i]); prev = lower_bound(a.begin(), a.end(), pos) - a.begin() - i; }else{ pos = *lower_bound(a.begin() + i, a.end(), b[i]); prev = lower_bound(b.begin(), b.end(), pos) - b.begin() - i; } ans *= prev; ans %= mod; } std::cout << ans << std::endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | kurikazu |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 802 Byte |
Status | AC |
Exec Time | 109 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 | 63 ms | 768 KB |
001.txt | AC | 23 ms | 384 KB |
002.txt | AC | 32 ms | 512 KB |
003.txt | AC | 36 ms | 512 KB |
004.txt | AC | 92 ms | 896 KB |
005.txt | AC | 107 ms | 1024 KB |
006.txt | AC | 109 ms | 1024 KB |
007.txt | AC | 108 ms | 1024 KB |
008.txt | AC | 109 ms | 1024 KB |
009.txt | AC | 105 ms | 1024 KB |
010.txt | AC | 105 ms | 1024 KB |
011.txt | AC | 106 ms | 1024 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 2 ms | 256 KB |