Submission #2011466


Source Code Expand

#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60, lmod = 1e9+7;

const int MAX_N = 100005;
ll fact[MAX_N];
int right[2*MAX_N];
vector<P> vec;

int main(){
  ll N; cin >> N;
  rep(i,N){
    int a; scanf("%d",&a);
    vec.pb(P(a,1));
  }
  rep(i,N){
    int a; scanf("%d",&a);
    vec.pb(P(a,-1));
  }
  sort(ALL(vec));
  ll ans = 1LL;
  ll cnt = 0;
  int pre;
  rrep(i,2*N-1){
    if(cnt==0){
      pre = vec[i].second;
    }
    if(vec[i].second==pre){
      cnt++;
    }else{
      (ans *= cnt) %= lmod;
      cnt--;
    }
  }
  cout << ans << endl;
  return 0;
}

Submission Info

Submission Time
Task A - 1D Matching
User kurarrr
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1027 Byte
Status AC
Exec Time 41 ms
Memory 2420 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:28:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     int a; scanf("%d",&a);
                          ^
./Main.cpp:32:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     int a; scanf("%d",&a);
                          ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 14
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 1400 KB
001.txt AC 10 ms 892 KB
002.txt AC 13 ms 892 KB
003.txt AC 14 ms 1400 KB
004.txt AC 37 ms 2420 KB
005.txt AC 41 ms 2420 KB
006.txt AC 41 ms 2420 KB
007.txt AC 40 ms 2420 KB
008.txt AC 41 ms 2420 KB
009.txt AC 41 ms 2420 KB
010.txt AC 40 ms 2420 KB
011.txt AC 40 ms 2420 KB
example0.txt AC 1 ms 256 KB
example1.txt AC 1 ms 256 KB