Submission #1678298
Source Code Expand
#include<iostream> #include<vector> #include<algorithm> #define mod 1000000007 using namespace std; typedef long long int ll; typedef pair<ll,int> mypair; int main(void){ int n; cin>>n; vector<ll> a(n),b(n); vector<mypair> l; for(int i=0;i<n;i++){ cin>>a[i]; l.push_back(mypair(a[i],-1)); } for(int i=0;i<n;i++){ cin>>b[i]; l.push_back(mypair(b[i],1)); } sort(l.begin(),l.end()); ll ans=1; int f=0; for(int i=0;i<2*n;i++){ int c=l[i].second; if(f==0){ f+=c; }else if(f<0){ if(c<0){ f+=c; }else{ ans*=-1*f; ans%=mod; f+=c; } }else{ if(c>0){ f+=c; }else{ ans*=f; ans%=mod; f+=c; } } } cout<<ans<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | obata1234 |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 760 Byte |
Status | AC |
Exec Time | 101 ms |
Memory | 7664 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 | 60 ms | 3316 KB |
001.txt | AC | 23 ms | 1784 KB |
002.txt | AC | 31 ms | 1912 KB |
003.txt | AC | 35 ms | 2932 KB |
004.txt | AC | 89 ms | 7408 KB |
005.txt | AC | 99 ms | 6896 KB |
006.txt | AC | 101 ms | 6768 KB |
007.txt | AC | 100 ms | 7664 KB |
008.txt | AC | 99 ms | 6640 KB |
009.txt | AC | 99 ms | 7024 KB |
010.txt | AC | 98 ms | 6768 KB |
011.txt | AC | 99 ms | 6128 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |