Submission #4048933
Source Code Expand
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#define MAX_N (100000L)
#define NUM_MOD (1000000007L)
using namespace std;
int main(int argc, char *argv[]) {
// read inputs
long N, as[MAX_N], bs[MAX_N];
scanf("%ld", &N);
for (long i = 0; i < N; i++) {
scanf("%ld", &as[i]);
}
for (long i = 0; i < N; i++) {
scanf("%ld", &bs[i]);
}
// NOTE : modified input
sort(as, as + N);
sort(bs, bs + N);
// record factorial
long fs[MAX_N + 1];
fs[0] = 1;
for (long k = 1; k <= N; k++) {
fs[k] = (fs[k - 1] * k) % NUM_MOD;
}
// solve
long ia = 0, ib = 0, ans = 1;
while (ia < N && ib < N) {
long num;
if (as[ia] <= bs[ib]) {
for (num = 0; ia + num < N; num++) {
if (as[ia + num] > bs[ib]) {
break;
}
}
} else {
for (num = 0; ib + num < N; num++) {
if (bs[ia + num] > as[ia]) {
break;
}
}
}
// printf("ia = %ld, ib = %ld, num = %ld, fs[num] = %ld\n", ia, ib, num,
// fs[num]);
ans = (ans * fs[num]) % NUM_MOD;
ia += num;
ib += num;
}
printf("%ld\n", ans);
return 0;
}
Submission Info
Submission Time |
|
Task |
A - 1D Matching |
User |
khir |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1202 Byte |
Status |
WA |
Exec Time |
36 ms |
Memory |
2560 KB |
Compile Error
./Main.cpp: In function ‘int main(int, char**)’:
./Main.cpp:13:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%ld", &N);
^
./Main.cpp:15:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%ld", &as[i]);
^
./Main.cpp:18:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%ld", &bs[i]);
^
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 |
22 ms |
1536 KB |
001.txt |
WA |
8 ms |
640 KB |
002.txt |
WA |
11 ms |
2432 KB |
003.txt |
WA |
12 ms |
1024 KB |
004.txt |
WA |
32 ms |
2432 KB |
005.txt |
WA |
36 ms |
2560 KB |
006.txt |
WA |
36 ms |
2560 KB |
007.txt |
WA |
36 ms |
2560 KB |
008.txt |
WA |
36 ms |
2560 KB |
009.txt |
WA |
36 ms |
2560 KB |
010.txt |
AC |
36 ms |
2560 KB |
011.txt |
AC |
36 ms |
2560 KB |
example0.txt |
AC |
1 ms |
128 KB |
example1.txt |
AC |
1 ms |
128 KB |