Submission #2715083
Source Code Expand
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define inf (int)(1e18)
#define p (int)(1e9 + 7)
signed compare(const void *a, const void *b){
int sub = *(int *)a - *(int *)b;
if(sub < 0){
return -1;
}
else if(sub == 0){
return 0;
}
else{
return 1;
}
}
signed main(){
int N, i, j, k, ans = 1;
scanf("%lld", &N);
int *a = (int *)malloc(sizeof(int) * (N + 1));
int *b = (int *)malloc(sizeof(int) * (N + 1));
for(i = 0; i < N; i++){
scanf("%lld", &a[i]);
}
for(i = 0; i < N; i++){
scanf("%lld", &b[i]);
}
a[N] = inf;
b[N] = inf;
qsort(a, N, sizeof(int), compare);
qsort(b, N, sizeof(int), compare);
for(i = 0, j = 0, k = 0; i < N || j < N; k++){
if(a[i] < b[j]){
a[i] = k;
i++;
}
else{
b[j] = k;
j++;
}
}
int *c = (int *)malloc(sizeof(int) * (2 * N));
for(i = 0; i < 2 * N; i++){
c[i] = 0;
}
for(i = 0; i < N; i++){
if(a[i] < b[i]){
c[a[i]]++;
c[b[i]]--;
}
else{
c[a[i]]--;
c[b[i]]++;
}
}
for(i = 1; i < 2 * N; i++){
c[i] += c[i - 1];
}
for(i = 0; i < 2 * N - 1; i++){
if(c[i] > c[i + 1]){
ans = (ans * c[i]) % p;
}
}
printf("%lld\n", ans);
return 0;
}
Submission Info
Submission Time
2018-06-23 06:53:14+0900
Task
A - 1D Matching
User
abc050
Language
C (GCC 5.4.1)
Score
500
Code Size
1225 Byte
Status
AC
Exec Time
53 ms
Memory
4076 KB
Compile Error
./Main.c: In function ‘main’:
./Main.c:22:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld", &N);
^
./Main.c:26:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld", &a[i]);
^
./Main.c:29:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld", &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
31 ms
2592 KB
001.txt
AC
11 ms
976 KB
002.txt
AC
16 ms
1420 KB
003.txt
AC
18 ms
1520 KB
004.txt
AC
47 ms
3648 KB
005.txt
AC
52 ms
4076 KB
006.txt
AC
53 ms
4076 KB
007.txt
AC
52 ms
4076 KB
008.txt
AC
52 ms
4076 KB
009.txt
AC
52 ms
4076 KB
010.txt
AC
53 ms
4076 KB
011.txt
AC
52 ms
4076 KB
example0.txt
AC
1 ms
128 KB
example1.txt
AC
1 ms
128 KB