Submission #1000618


Source Code Expand

/* ***************************************
Author        :Scau.ion
Created Time  :2016/11/28 11:04:36 UTC+8
File Name     :ion.cpp
*************************************** */

#include <bits/stdc++.h>

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

using namespace std;

const int maxn=100010;
const int mod=1e9+7;

struct num
{
    int x;
    bool type;
    bool operator <(const num &b)const
    {
        return x<b.x;
    }
}ab[maxn*2];

int main()
{
    IOS;
    int n;
    cin>>n;
    int nn=n*2;
    for (int j=1;j<=nn;++j)
    {
        cin>>ab[j].x;
        ab[j].type=(j>n);
    }
    sort(ab+1,ab+n*2+1);
    LL ans=1;
    int sum=0;
    for (int j=1;j<=nn;++j)
    {
        int add;
        if (ab[j].type) add=1;
        else add=-1;
        if (!((sum<=0&&add<0)||(sum>=0&&add>0))) ans=ans*abs(sum)%mod;
        sum+=add;
    }
    cout<<ans<<endl;
    return 0;
}

Submission Info

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

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 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 34 ms 1664 KB
005.txt AC 38 ms 1792 KB
006.txt AC 38 ms 1792 KB
007.txt AC 38 ms 1792 KB
008.txt AC 38 ms 1792 KB
009.txt AC 39 ms 1792 KB
010.txt AC 38 ms 1792 KB
011.txt AC 38 ms 1792 KB
example0.txt AC 2 ms 256 KB
example1.txt AC 2 ms 256 KB