Submission #3278333
Source Code Expand
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int,int> P; constexpr double EPS = 1e-12; constexpr int INF = numeric_limits<int>::max()/2; constexpr int MOD = 1e9+7; int main(){ cin.tie(0); ios::sync_with_stdio(false); int n;cin>>n; vector<P> v; for(int i=0;i<n;i++){ ll a;cin>>a; v.push_back(P(a,0)); } for(int i=0;i<n;i++){ ll b;cin>>b; v.push_back(P(b,1)); } sort(v.begin(),v.end()); ll acnt=0,bcnt=0; ll res=1; for(int i=0;i<2*n;i++){ if(v[i].second==0){ if(bcnt){ res *= bcnt; res %= MOD; bcnt--; continue; } acnt++; } else{ if(acnt){ res *= acnt; res %= MOD; acnt--; continue; } bcnt++; } } cout<<res<<endl; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | zaki_ |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 935 Byte |
Status | AC |
Exec Time | 38 ms |
Memory | 3444 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 | 23 ms | 1400 KB |
001.txt | AC | 9 ms | 892 KB |
002.txt | AC | 12 ms | 892 KB |
003.txt | AC | 13 ms | 1400 KB |
004.txt | AC | 34 ms | 2420 KB |
005.txt | AC | 37 ms | 2420 KB |
006.txt | AC | 38 ms | 2420 KB |
007.txt | AC | 37 ms | 2420 KB |
008.txt | AC | 37 ms | 2420 KB |
009.txt | AC | 37 ms | 3444 KB |
010.txt | AC | 37 ms | 2420 KB |
011.txt | AC | 37 ms | 2420 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |