Submission #2411538
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define ll long long const ll pri = 1000000007; typedef pair<int, int>P; int main(){ ll N, ans = 1; cin>>N; vector<P>vec; for(int i=0;i<N;i++){ int tmp; cin>>tmp; vec.push_back(P(tmp, 0)); } for(int i=0;i<N;i++){ int tmp; cin>>tmp; vec.push_back(P(tmp, 1)); } sort(vec.begin(), vec.end()); int lst[2] = {0, 0}; for(int i=0;i<vec.size();i++){ if(vec[i].second){ if(lst[0]>0){ lst[0]--; } else{ lst[1]++; ans = ans * lst[1] % pri; } } else{ if(lst[1]>0){ lst[1]--; } else{ lst[0]++; ans = ans * lst[0]%pri; } } } cout<<ans<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | kagasan |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 952 Byte |
Status | AC |
Exec Time | 97 ms |
Memory | 2420 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 | 1400 KB |
001.txt | AC | 22 ms | 892 KB |
002.txt | AC | 30 ms | 892 KB |
003.txt | AC | 33 ms | 1400 KB |
004.txt | AC | 86 ms | 2420 KB |
005.txt | AC | 96 ms | 2420 KB |
006.txt | AC | 96 ms | 2420 KB |
007.txt | AC | 96 ms | 2420 KB |
008.txt | AC | 96 ms | 2420 KB |
009.txt | AC | 96 ms | 2420 KB |
010.txt | AC | 97 ms | 2420 KB |
011.txt | AC | 96 ms | 2420 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |