Submission #1000598
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))
// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD
// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;
int n;
int a[125252];
int b[125252];
int main(){
scanf("%d",&n);
REP(i,n)scanf("%d",a+i);
REP(i,n)scanf("%d",b+i);
sort(a,a+n);
sort(b,b+n);
int ait = 0, bit = 0;
int acnt = 0, bcnt = 0;
ll ans = 1;
REP(_,2*n){
if(ait<n && (bit==n || a[ait]<b[bit])){
// choose a
if(bcnt > 0){
ans = ans*bcnt%MOD;
bcnt--;
}else{
acnt++;
}
ait++;
}else{
// choose b
if(acnt > 0){
ans = ans*acnt%MOD;
acnt--;
}else{
bcnt++;
}
bit++;
}
}
printf("%lld\n",ans);
return 0;
}
Submission Info
Submission Time |
|
Task |
A - 1D Matching |
User |
rickytheta |
Language |
C++14 (GCC 5.4.1) |
Score |
500 |
Code Size |
1503 Byte |
Status |
AC |
Exec Time |
40 ms |
Memory |
1024 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:39:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
./Main.cpp:40:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
REP(i,n)scanf("%d",a+i);
^
./Main.cpp:41:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
REP(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 |
768 KB |
001.txt |
AC |
10 ms |
384 KB |
002.txt |
AC |
14 ms |
512 KB |
003.txt |
AC |
15 ms |
512 KB |
004.txt |
AC |
36 ms |
896 KB |
005.txt |
AC |
40 ms |
1024 KB |
006.txt |
AC |
40 ms |
1024 KB |
007.txt |
AC |
40 ms |
1024 KB |
008.txt |
AC |
40 ms |
1024 KB |
009.txt |
AC |
40 ms |
1024 KB |
010.txt |
AC |
40 ms |
1024 KB |
011.txt |
AC |
40 ms |
1024 KB |
example0.txt |
AC |
3 ms |
256 KB |
example1.txt |
AC |
3 ms |
256 KB |