Submission #1403813
Source Code Expand
#include<bits/stdc++.h>
#define N 100005
using namespace std;
const int mod=1e9+7;
int n;
struct msg{
int pos,val;
bool operator <(const msg &b)const{
return pos<b.pos;
}
}a[N*2];
int ans;
int main(){
scanf("%d",&n);ans=1;
for(int i=1;i<=n;i++) scanf("%d",&a[i].pos),a[i].val=1;
for(int i=n+1;i<=n+n;i++) scanf("%d",&a[i].pos),a[i].val=-1;
sort(a+1,a+n*2+1);
int tot=0;
for(int i=1;i<=n*2;i++){
if(tot*a[i].val>=0) tot+=a[i].val;
else ans=ans*1LL*abs(tot)%mod,tot+=a[i].val;
}
cout<<ans<<endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
A - 1D Matching |
User |
Wuvin |
Language |
C++14 (GCC 5.4.1) |
Score |
500 |
Code Size |
547 Byte |
Status |
AC |
Exec Time |
39 ms |
Memory |
1792 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:14:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);ans=1;
^
./Main.cpp:15:56: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
for(int i=1;i<=n;i++) scanf("%d",&a[i].pos),a[i].val=1;
^
./Main.cpp:16:61: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
for(int i=n+1;i<=n+n;i++) scanf("%d",&a[i].pos),a[i].val=-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 |
34 ms |
1664 KB |
005.txt |
AC |
39 ms |
1792 KB |
006.txt |
AC |
39 ms |
1792 KB |
007.txt |
AC |
38 ms |
1792 KB |
008.txt |
AC |
39 ms |
1792 KB |
009.txt |
AC |
39 ms |
1792 KB |
010.txt |
AC |
39 ms |
1792 KB |
011.txt |
AC |
38 ms |
1792 KB |
example0.txt |
AC |
1 ms |
256 KB |
example1.txt |
AC |
1 ms |
256 KB |