Submission #1163485
Source Code Expand
#include<bits/stdc++.h>
#define pii pair<int,int>
#define rep(i,j,k) for(int i=(int)j;i<=(int)k;i++)
#define per(i,j,k) for(int i=(int)j;i>=(int)k;i--)
using namespace std;
const int P=1000000007;
const int N=210000;
pii a[N];int n;
int main(){
scanf("%d",&n);
rep(i,1,n){
scanf("%d",&a[i].first);a[i].second=-1;
}
rep(i,1,n){
scanf("%d",&a[i+n].first);a[i+n].second=1;
}
sort(a+1,a+1+2*n);
int ans=1;
int pre=0;
rep(i,1,2*n){
if(pre==0){
pre+=a[i].second;
}
else{
if(a[i].second*pre>0)pre+=a[i].second;
else{
ans=ans*1ll*abs(pre)%P;
pre+=a[i].second;
}
}
}
printf("%d\n",ans);
return 0;
}
Submission Info
Submission Time |
|
Task |
A - 1D Matching |
User |
skydec |
Language |
C++14 (GCC 5.4.1) |
Score |
500 |
Code Size |
802 Byte |
Status |
AC |
Exec Time |
40 ms |
Memory |
1792 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:10:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
./Main.cpp:12:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&a[i].first);a[i].second=-1;
^
./Main.cpp:15:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&a[i+n].first);a[i+n].second=1;
^
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 |
12 ms |
768 KB |
003.txt |
AC |
14 ms |
768 KB |
004.txt |
AC |
35 ms |
1664 KB |
005.txt |
AC |
39 ms |
1792 KB |
006.txt |
AC |
40 ms |
1792 KB |
007.txt |
AC |
39 ms |
1792 KB |
008.txt |
AC |
40 ms |
1792 KB |
009.txt |
AC |
39 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 |