Submission #3623789


Source Code Expand

#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
ll mod = 1e9+7;
pii a[200005];
int main(){
    int n;
    scanf("%d", &n);
    rep(i,2*n){
        scanf("%d", &a[i].first);
        a[i].second = i;
    }
    sort(a,a+2*n);
    ll ans = 1;
    int hoge = 0;
    rep(i,2*n){
        if(a[i].second < n){
            if(hoge< 0) ans = ans * (-hoge) % mod;
            hoge++;
        }else{
            if(hoge > 0) ans = ans * hoge % mod;
            hoge--;
        }
    }
    printf("%lld\n", ans);
}

Submission Info

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

Compile Error

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

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 1152 KB
001.txt AC 10 ms 640 KB
002.txt AC 13 ms 768 KB
003.txt AC 14 ms 768 KB
004.txt AC 37 ms 1664 KB
005.txt AC 41 ms 1792 KB
006.txt AC 41 ms 1792 KB
007.txt AC 41 ms 1792 KB
008.txt AC 41 ms 1792 KB
009.txt AC 41 ms 1792 KB
010.txt AC 40 ms 1792 KB
011.txt AC 40 ms 1792 KB
example0.txt AC 1 ms 256 KB
example1.txt AC 1 ms 256 KB