Submission #2443568
Source Code Expand
#include <iostream> #include <vector> #include <algorithm> #include <utility> using namespace std; typedef pair<int,int> P; typedef long long ll; ll N,a; ll inf = 1e9+7; ll F[100010] = {0}; int main(){ cin >> N; F[0] = 1; for(int i=1;i<=N;i++){ F[i] = (i*F[i-1])%inf; } vector<P> v(2*N); for(int i=0;i<2*N;i++){ if(i<N){ cin >> a; v[i] = P(a,1); }else{ cin >> a; v[i] = P(a,-1); } } sort(v.begin(),v.end()); ll c = 0,ma = 0; ll ans = 1; for(int i=0;i<2*N;i++){ c += v[i].second; ma = max(ma,c); if(c==0){ (ans *= F[ma])%inf; ma = 0; } } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | idsigma |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 647 Byte |
Status | WA |
Exec Time | 97 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 | 22 ms | 768 KB |
002.txt | WA | 30 ms | 1024 KB |
003.txt | WA | 33 ms | 1024 KB |
004.txt | WA | 86 ms | 2304 KB |
005.txt | WA | 97 ms | 2560 KB |
006.txt | WA | 96 ms | 2560 KB |
007.txt | WA | 96 ms | 2560 KB |
008.txt | WA | 97 ms | 2560 KB |
009.txt | WA | 96 ms | 2560 KB |
010.txt | WA | 96 ms | 2560 KB |
011.txt | AC | 96 ms | 2560 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |