Submission #3388496
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { const int MOD = 1000000007; int n; cin >> n; vector<ll> factorial(n+1, 1); for (int i = 2; i < n+1; ++i) { factorial[i] *= i; factorial[i] %= MOD; } vector<pair<ll, int> > ab(2 * n); for (int i = 0; i < n; ++i) { cin >> ab[i].first; ab[i].second = 1; } for (int i = n; i < 2 * n; ++i) { cin >> ab[i].first; ab[i].second = -1; } sort(ab.begin(), ab.end()); int cnt = 0; int num = 0; ll ans = 1; for (int i = 0; i < 2*n; ++i) { cnt += ab[i].second; if (ab[i].second == 1 && cnt > 0) { num++; } else if (ab[i].second == -1 && cnt < 0) { num++; } else if (cnt == 0) { ans *= factorial[num]; ans %= MOD; num = 0; } } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | anagohirame |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 853 Byte |
Status | WA |
Exec Time | 96 ms |
Memory | 4096 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 | 2560 KB |
001.txt | WA | 21 ms | 1152 KB |
002.txt | WA | 30 ms | 1408 KB |
003.txt | WA | 37 ms | 1536 KB |
004.txt | WA | 85 ms | 3712 KB |
005.txt | WA | 95 ms | 4096 KB |
006.txt | WA | 96 ms | 4096 KB |
007.txt | WA | 95 ms | 4096 KB |
008.txt | WA | 95 ms | 4096 KB |
009.txt | WA | 95 ms | 4096 KB |
010.txt | WA | 94 ms | 4096 KB |
011.txt | AC | 96 ms | 4096 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |