Submission #1834414
Source Code Expand
#include <algorithm>
#include <cstdio>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define whole(x) begin(x), end(x)
using ll = long long;
using namespace std;
constexpr int mod = 1e9+7;
int main() {
// input
int n; scanf("%d", &n);
vector<int> a(n); repeat (i, n) scanf("%d", &a[i]);
vector<int> b(n); repeat (i, n) scanf("%d", &b[i]);
// solve
vector<pair<int, bool> > events;
repeat (i, n) {
events.emplace_back(a[i], false);
events.emplace_back(b[i], true);
}
sort(whole(events));
ll result = 1;
int cnt = 0;
for (auto event : events) {
int delta = (event.second ? 1 : -1);
if (cnt != 0 and (cnt > 0) != event.second) {
result = (result * std::abs(cnt)) % mod;
}
cnt += delta;
}
// output
printf("%lld\n", result);
return 0;
}
Submission Info
Submission Time |
|
Task |
A - 1D Matching |
User |
kimiyuki |
Language |
C++14 (GCC 5.4.1) |
Score |
500 |
Code Size |
922 Byte |
Status |
AC |
Exec Time |
42 ms |
Memory |
3188 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:12:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
int n; scanf("%d", &n);
^
./Main.cpp:13:55: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
vector<int> a(n); repeat (i, n) scanf("%d", &a[i]);
^
./Main.cpp:14:55: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
vector<int> b(n); repeat (i, n) scanf("%d", &b[i]);
^
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 |
25 ms |
1912 KB |
001.txt |
AC |
10 ms |
1020 KB |
002.txt |
AC |
13 ms |
1148 KB |
003.txt |
AC |
15 ms |
1656 KB |
004.txt |
AC |
37 ms |
3060 KB |
005.txt |
AC |
42 ms |
3188 KB |
006.txt |
AC |
42 ms |
3188 KB |
007.txt |
AC |
42 ms |
3188 KB |
008.txt |
AC |
42 ms |
3188 KB |
009.txt |
AC |
42 ms |
3188 KB |
010.txt |
AC |
41 ms |
3188 KB |
011.txt |
AC |
41 ms |
3188 KB |
example0.txt |
AC |
1 ms |
256 KB |
example1.txt |
AC |
1 ms |
256 KB |