Submission #3226338
Source Code Expand
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define i_7 (ll)(1E9+7) #define i_5 (ll)(1E9+5) ll mod(ll a){ ll c=a%i_7; if(c>=0)return c; else return c+i_7; } typedef pair<int,int> i_i; typedef pair<ll,ll> l_l; ll inf=(ll)1E12;//10^12 #define rep(i,l,r) for(ll i=l;i<=r;i++) #define pb push_back ll max(ll a,ll b){if(a<b)return b;else return a;} ll min(ll a,ll b){if(a>b)return b;else return a;} //////////////////////////////////////// int main(){ ios::sync_with_stdio(false);cin.tie(0); ll n;cin>>n; l_l a[2*n]; rep(i,0,n-1){ ll b;cin>>b;a[i]=i_i(b,1); } rep(i,0,n-1){ ll b;cin>>b;a[i+n]=i_i(b,2); } sort(a,a+2*n); ll ans=1; int c=0; rep(i,0,2*n-1){ if(a[i].second==1){ if(c<0){ ans=mod(ans*(-c)); } c++; }else{ if(c>0){ ans=mod(ans*c); } c--; } } cout<<ans<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | sugarrr |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 1067 Byte |
Status | AC |
Exec Time | 37 ms |
Memory | 3328 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 | 22 ms | 2176 KB |
001.txt | AC | 8 ms | 896 KB |
002.txt | AC | 12 ms | 1280 KB |
003.txt | AC | 13 ms | 1280 KB |
004.txt | AC | 33 ms | 3072 KB |
005.txt | AC | 37 ms | 3328 KB |
006.txt | AC | 36 ms | 3328 KB |
007.txt | AC | 36 ms | 3328 KB |
008.txt | AC | 37 ms | 3328 KB |
009.txt | AC | 36 ms | 3328 KB |
010.txt | AC | 36 ms | 3328 KB |
011.txt | AC | 36 ms | 3328 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |