Submission #1084647
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long lint; typedef pair<int, int> pi; const int mod = 1e9 + 7; int n; pi a[200005]; int main(){ scanf("%d",&n); for(int i=0; i<n; i++){ scanf("%d",&a[i].first); a[i].second = 1; } for(int i=0; i<n; i++){ scanf("%d",&a[i+n].first); a[i+n].second = 2; } sort(a, a+2*n); int cnt = 0; lint ans = 1; for(int i=0; i<2*n; i++){ if(a[i].second == 1){ if(cnt < 0){ ans *= -cnt; ans %= mod; } cnt++; } else{ if(cnt > 0){ ans *= cnt; ans %= mod; } cnt--; } } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | koosaga |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 633 Byte |
Status | AC |
Exec Time | 43 ms |
Memory | 1792 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:11:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&n); ^ ./Main.cpp:13:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&a[i].first); ^ ./Main.cpp:17:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&a[i+n].first); ^
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 | 27 ms | 1152 KB |
001.txt | AC | 11 ms | 640 KB |
002.txt | AC | 15 ms | 768 KB |
003.txt | AC | 16 ms | 768 KB |
004.txt | AC | 38 ms | 1664 KB |
005.txt | AC | 43 ms | 1792 KB |
006.txt | AC | 43 ms | 1792 KB |
007.txt | AC | 43 ms | 1792 KB |
008.txt | AC | 43 ms | 1792 KB |
009.txt | AC | 43 ms | 1792 KB |
010.txt | AC | 42 ms | 1792 KB |
011.txt | AC | 42 ms | 1792 KB |
example0.txt | AC | 3 ms | 256 KB |
example1.txt | AC | 3 ms | 256 KB |