Submission #1003147


Source Code Expand

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iostream>
#include <cassert>
#include <cmath>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>

using namespace std;

#define TASKNAME ""

void solve(int test_number);

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(ios::fixed);
    cout.precision(9);
    cerr.setf(ios::fixed);
    cerr.precision(3);
#ifdef LOCAL
    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout);
#else
#endif
    int n = 1;
    for (int i = 0; i < n; i++) {
        solve(i);
    }
}

const int MAX_N = 100005;
const int MOD = 1000000007;


int n, a[MAX_N], b[MAX_N], fact[MAX_N];

void solve(int test_number) {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < n; i++) {
        scanf("%d", &b[i]);
    }
    sort(a, a + n);
    sort(b, b + n);
    long long ans = 1;
    int var = 0;
    int i = 0, j = 0;
    while (i < n || j < n) {
        if (i == n || (var == 0 && a[i] < b[j])) {
            swap(a, b);
            swap(i, j);
        }
        while (j < n && b[j] < a[i]) {
            var++;
            j++;
        }
        i++;
        ans = ans * var % MOD;
        var--;
    }
    cout << ans << endl;
}

Submission Info

Submission Time
Task A - 1D Matching
User Sarkin
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1411 Byte
Status TLE
Exec Time 2102 ms
Memory 1024 KB

Compile Error

./Main.cpp: In function ‘void solve(int)’:
./Main.cpp:45:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
                    ^
./Main.cpp:47:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a[i]);
                           ^
./Main.cpp:50:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &b[i]);
                           ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 2
AC × 13
TLE × 1
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 30 ms 1024 KB
001.txt AC 18 ms 1024 KB
002.txt AC 30 ms 1024 KB
003.txt AC 26 ms 1024 KB
004.txt AC 60 ms 1024 KB
005.txt AC 83 ms 1024 KB
006.txt AC 64 ms 1024 KB
007.txt AC 65 ms 1024 KB
008.txt AC 52 ms 1024 KB
009.txt AC 65 ms 1024 KB
010.txt AC 39 ms 1024 KB
011.txt TLE 2102 ms 1024 KB
example0.txt AC 4 ms 1024 KB
example1.txt AC 4 ms 1024 KB