Submission #5031016
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define int long long const int MOD = 1000000007; signed 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]; sort(a,a+n); sort(b,b+n); int p=0,q,x=0,y=0,ans=1; while(x<n&&y<n){ if(a[x]<b[y]){ q=p+1; x++; }else { q=p-1; y++; } if(abs(p)>abs(q))ans=(ans*abs(p))%MOD; p=q; } while(x<n){ ans=(ans*abs(p))%MOD; p++; x++; } while(y<n){ ans=(ans*abs(p))%MOD; p--; y++; } cout<<ans; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | yatuba |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 746 Byte |
Status | AC |
Exec Time | 92 ms |
Memory | 1792 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 | 1152 KB |
001.txt | AC | 21 ms | 640 KB |
002.txt | AC | 29 ms | 768 KB |
003.txt | AC | 32 ms | 768 KB |
004.txt | AC | 82 ms | 1664 KB |
005.txt | AC | 92 ms | 1792 KB |
006.txt | AC | 91 ms | 1792 KB |
007.txt | AC | 92 ms | 1792 KB |
008.txt | AC | 91 ms | 1792 KB |
009.txt | AC | 92 ms | 1792 KB |
010.txt | AC | 91 ms | 1792 KB |
011.txt | AC | 92 ms | 1792 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |