Submission #3643027
Source Code Expand
#include <iostream> #include <algorithm> #include <vector> #include <iomanip> #include <map> #include <queue> static const int MOD = 1000000007; using ll = long long; using u32 = unsigned; using namespace std; template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208; int main() { int n; cin >> n; vector<pair<int, int>> v(2*n); for (int i = 0; i < n; ++i) { int a; scanf("%d", &a); v[i] = make_pair(a, 0); } for (int i = 0; i < n; ++i) { int a; scanf("%d", &a); v[n+i] = make_pair(a, 1); } sort(v.begin(), v.end()); int k = v[0].second, u = 1; ll ans = 1; for (int i = 1; i < 2*n; ++i) { if(u == 0){ k = v[i].second; u = 1; continue; } if(v[i].second == k) u++; else { (ans *= u) %= MOD; u--; } } cout << ans << "\n"; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | firiexp |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 989 Byte |
Status | AC |
Exec Time | 40 ms |
Memory | 1920 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:21:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] int a; scanf("%d", &a); ^ ./Main.cpp:25:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] int a; scanf("%d", &a); ^
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 | 24 ms | 1152 KB |
001.txt | AC | 9 ms | 640 KB |
002.txt | AC | 13 ms | 768 KB |
003.txt | AC | 14 ms | 768 KB |
004.txt | AC | 35 ms | 1664 KB |
005.txt | AC | 40 ms | 1792 KB |
006.txt | AC | 40 ms | 1920 KB |
007.txt | AC | 39 ms | 1792 KB |
008.txt | AC | 40 ms | 1792 KB |
009.txt | AC | 40 ms | 1792 KB |
010.txt | AC | 39 ms | 1792 KB |
011.txt | AC | 39 ms | 1792 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |