Submission #3747606


Source Code Expand

#include <bits/stdc++.h>
#define maxn 200005
#define oo 1e9+5
#define foru(a,b,c) for (int a=b;a<=c;a++)
#define ford(a,b,c) for (int a=b;a>=c;a--)
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define ll long long
#define forv(a,b) for(auto&a:b)
#define base 1000000007
using namespace std;
struct data
{
    int x,t;
};
bool cmp(data p1,data p2)
{
    return p1.x<p2.x;
}
int n;
data a[maxn];
int main()
{
    ios_base::sync_with_stdio(0);
    //freopen("connect.inp", "r", stdin);
    //freopen("connect.out", "w", stdout);
    cin >> n;
    foru(i,1,n)
    {
        cin >> a[i].x;
        a[i].t=1;
    }
    foru(i,n+1,2*n)
    {
        cin >> a[i].x;
        a[i].t=2;
    }
    sort(a+1,a+2*n+1,cmp);
    multiset<int> h1,h2;
    ll kq=1;
    foru(i,1,2*n)
    {
        if (a[i].t==1)
        {
            if (h2.size()==0) h1.insert(a[i].x);
            else
            {
                kq=(kq*h2.size())%base;
                h2.erase(h2.begin());
            }
        }
        else
        {
            if (h1.size()==0) h2.insert(a[i].x);
            else
            {
                kq=(kq*h1.size())%base;
                h1.erase(h1.begin());
            }
        }
    }
    cout << kq;
}

Submission Info

Submission Time
Task A - 1D Matching
User boychienga1234
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1301 Byte
Status AC
Exec Time 65 ms
Memory 6528 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 30 ms 1280 KB
001.txt AC 11 ms 640 KB
002.txt AC 16 ms 768 KB
003.txt AC 17 ms 768 KB
004.txt AC 44 ms 1664 KB
005.txt AC 49 ms 1792 KB
006.txt AC 49 ms 1792 KB
007.txt AC 49 ms 1792 KB
008.txt AC 50 ms 1792 KB
009.txt AC 49 ms 1792 KB
010.txt AC 65 ms 6528 KB
011.txt AC 46 ms 1792 KB
example0.txt AC 1 ms 256 KB
example1.txt AC 1 ms 256 KB