Submission #1480308


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

const int MOD = 1e9 + 7;
const int MAX = 1e5 + 10;
int n;
long long a[MAX], b[MAX];
pair<long long, bool> ab[MAX * 2];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%lld", a + i);
    }
    sort(a, a + n);
    for (int i = 0; i < n; i++) {
        scanf("%lld", b + i);
    }
    sort(b, b + n);
    long long ans = 1;

    for (int i = 0; i < n; i++) {
        ab[i] = make_pair(a[i], false);
    }
    for (int i = 0; i < n; i++) {
        ab[n + i] = make_pair(b[i], true);
    }
    sort(ab, ab + 2 * n);
    int cnt = 0;
    for (int i = 0; i < n * 2; i++) {
        if (ab[i].second) {
            // com
            if (cnt > 0) {
                (ans *= cnt) %= MOD;
            }
            cnt--;
        } else {
            // el
            if (cnt < 0) {
                (ans *= -cnt) %= MOD;
            }
            cnt++;
        }
    }

    printf("%d\n", ans);
    return 0;
}

Submission Info

Submission Time
Task A - 1D Matching
User sekiya9311
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1034 Byte
Status AC
Exec Time 56 ms
Memory 4992 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:47:23: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
     printf("%d\n", ans);
                       ^
./Main.cpp:12:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
                    ^
./Main.cpp:14:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", a + i);
                             ^
./Main.cpp:18:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", b + i);
                             ^

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 34 ms 4480 KB
001.txt AC 12 ms 2944 KB
002.txt AC 17 ms 3328 KB
003.txt AC 18 ms 3456 KB
004.txt AC 50 ms 4864 KB
005.txt AC 56 ms 4992 KB
006.txt AC 56 ms 4992 KB
007.txt AC 55 ms 4992 KB
008.txt AC 56 ms 4992 KB
009.txt AC 56 ms 4992 KB
010.txt AC 41 ms 4992 KB
011.txt AC 56 ms 4992 KB
example0.txt AC 1 ms 2304 KB
example1.txt AC 2 ms 2304 KB