Submission #4087478


Source Code Expand

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

const ll mod = 1000000007;

int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);

    int N;
    cin >> N;
    ll A[N], B[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }

    sort(A, A+N);
    sort(B, B+N);

    ll ans = 1LL, a = 0, b = 0, st = 0;
    for (int i = 0; i < 2 * N; i++) {
        if (a < N && A[a] < B[b]) {
            a++;
            if (a <= b) {
                ans = (ans * max(0LL, b - st)) % mod;
                st++;
            }
        } else {
            b++;
            if (b <= a) {
                ans = (ans * max(0LL, a - st)) % mod;
                st++;
            }
        }
    }

    cout << ans << "\n";
    return 0;
}

Submission Info

Submission Time
Task A - 1D Matching
User veqcc
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1068 Byte
Status WA
Exec Time 35 ms
Memory 1792 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 2
AC × 10
WA × 4
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 21 ms 1152 KB
001.txt AC 8 ms 640 KB
002.txt WA 11 ms 768 KB
003.txt AC 12 ms 768 KB
004.txt AC 31 ms 1664 KB
005.txt AC 35 ms 1792 KB
006.txt WA 34 ms 1792 KB
007.txt AC 34 ms 1792 KB
008.txt AC 34 ms 1792 KB
009.txt WA 34 ms 1792 KB
010.txt WA 34 ms 1792 KB
011.txt AC 34 ms 1792 KB
example0.txt AC 1 ms 256 KB
example1.txt AC 1 ms 256 KB