Submission #4998761
Source Code Expand
#include<bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int main(){ int N; cin >> N; 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]; } vector<pair<int , int>> P; for(int i=0; i<2*N; i++){ if(i < N){ P.push_back({a[i], 0}); }else{ P.push_back({b[i-N], 1}); } } sort(P.begin(), P.end()); long long ans = 1; int cnt = 0, c; for(int i=2*N-1; i>=0; i--){ if(cnt == 0){ c = P[i].second; } if(P[i].second != c){ ans = (ans * cnt) % mod; cnt--; }else{ cnt++; } } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | Ju_Ga_Me |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 641 Byte |
Status | AC |
Exec Time | 98 ms |
Memory | 3188 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 | 59 ms | 1912 KB |
001.txt | AC | 22 ms | 1020 KB |
002.txt | AC | 30 ms | 1148 KB |
003.txt | AC | 34 ms | 1656 KB |
004.txt | AC | 87 ms | 3060 KB |
005.txt | AC | 98 ms | 3188 KB |
006.txt | AC | 97 ms | 3188 KB |
007.txt | AC | 98 ms | 3188 KB |
008.txt | AC | 98 ms | 3188 KB |
009.txt | AC | 98 ms | 3188 KB |
010.txt | AC | 97 ms | 3188 KB |
011.txt | AC | 97 ms | 3188 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |