Submission #3877506
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(ll (i) = (0);(i) < (n);++i) #define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i) #define PB push_back #define EB emplace_back #define MP make_pair #define FI first #define SE second #define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;} #define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;} #define ALL(v) v.begin(),v.end() #define Decimal fixed<<setprecision(20) #define INF 1000000000 #define LLINF 1000000000000000000LL #define MOD 1000000007 typedef long long ll; typedef pair<ll,ll> P; int main(){ int n;cin >> n; vector<ll> A(n);REP(i,n)cin >> A[i];sort(ALL(A)); vector<ll> B(n);REP(i,n)cin >> B[i];sort(ALL(B)); vector<ll> num(n); ll ans = 1; ll AA = 0; ll cou = 0; REP(i,n){ if(cou == 0 && A[cou] > B[i]){ AA++; continue; } while(cou < n - 1 && A[cou+1] < B[i])cou++; num[cou]++; } //SHOW1d(num,n); cou = 0; REP(i,n){ bool flag = true; cou++; if(AA > 0){ ans *= AA; ans %= MOD; cou--; flag = false; } if(flag && num[i] > 0){ ll tmp = 1; while(cou > 0 && num[i] > 0){ tmp *= cou; tmp %= MOD; cou--; num[i]--; } ans *= tmp; ans %= MOD; } AA += num[i]; } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | seica |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1404 Byte |
Status | WA |
Exec Time | 94 ms |
Memory | 2560 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | WA | 58 ms | 1664 KB |
001.txt | WA | 21 ms | 768 KB |
002.txt | WA | 29 ms | 1024 KB |
003.txt | WA | 32 ms | 1024 KB |
004.txt | WA | 84 ms | 2304 KB |
005.txt | WA | 94 ms | 2560 KB |
006.txt | WA | 93 ms | 2560 KB |
007.txt | WA | 93 ms | 2560 KB |
008.txt | WA | 93 ms | 2560 KB |
009.txt | WA | 94 ms | 2560 KB |
010.txt | WA | 93 ms | 2560 KB |
011.txt | WA | 93 ms | 2560 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |