Submission #1834465


Source Code Expand

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;

const int MOD = 1e9 + 7;

int main() {
        int n;
        scanf("%d", &n);
        vector<pair<long long, int>> a(2 * n);
        for (int i = 0; i < 2 * n; i ++) {
                scanf("%lld", &a[i].first);
                if (i < n) a[i].second = 1;
                else a[i].second = -1;
        }
        sort(a.begin(), a.end());
        int total = 0;
        long long ans = 1;
        for (int i = 0; i < 2 * n; i ++) {
                int type = a[i].second;
                if (type > 0 && total < 0) ans = ans * -total % MOD;
                if (type < 0 && total > 0) ans = ans * total % MOD;
                total += type;
        }
        printf("%lld\n", ans % MOD);
        return 0;
}

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:14:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &n);
                        ^
./Main.cpp:17:43: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
                 scanf("%lld", &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 24 ms 2176 KB
001.txt AC 9 ms 896 KB
002.txt AC 13 ms 1152 KB
003.txt AC 14 ms 1280 KB
004.txt AC 36 ms 3072 KB
005.txt AC 40 ms 3328 KB
006.txt AC 41 ms 3328 KB
007.txt AC 40 ms 3328 KB
008.txt AC 40 ms 3328 KB
009.txt AC 40 ms 3328 KB
010.txt AC 39 ms 3328 KB
011.txt AC 40 ms 3328 KB
example0.txt AC 1 ms 256 KB
example1.txt AC 1 ms 256 KB