Submission #1834351
Source Code Expand
#include <iostream> #include <algorithm> #include <vector> #include <string> using namespace std; struct INFO { int x, k; INFO(int x=0,int k=0):x(x),k(k){} bool operator<(const INFO& r)const { return x < r.x; } }; #define MOD (int)(1e9+7) int main() { int N; cin >> N; vector<INFO>AB(2 * N); for (int i = 0; i < N; i++) { int a; cin >> a; AB[i] = INFO(a, 0); } for (int i = 0; i < N; i++) { int b; cin >> b; AB[N+i] = INFO(b, 1); } sort(AB.begin(), AB.end()); long long ans = 1; int m = AB[0].k; int cnt = 0; for (int i = 0; i < 2*N; i++) { if (AB[i].k == m) { cnt++; } else { if (cnt == 0) { m = AB[i].k; cnt++; continue; } ans *= cnt; ans %= MOD; cnt--; } } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | kurenai3110 |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 821 Byte |
Status | AC |
Exec Time | 95 ms |
Memory | 1792 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 | 57 ms | 1152 KB |
001.txt | AC | 21 ms | 640 KB |
002.txt | AC | 29 ms | 768 KB |
003.txt | AC | 33 ms | 768 KB |
004.txt | AC | 85 ms | 1664 KB |
005.txt | AC | 95 ms | 1792 KB |
006.txt | AC | 94 ms | 1792 KB |
007.txt | AC | 94 ms | 1792 KB |
008.txt | AC | 94 ms | 1792 KB |
009.txt | AC | 95 ms | 1792 KB |
010.txt | AC | 94 ms | 1792 KB |
011.txt | AC | 94 ms | 1792 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |