Submission #1000572


Source Code Expand

#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;

const int MOD = (int) 1e9 + 7;

void smul(int &a, int b)
{
	a = (a * 1LL * b) % MOD;
}
const int N = (int) 1e5 + 100;
int a[N], b[N];


int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif


	int n;
	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);

	int pa = 0, pb = 0;
	
	int cnt = 0;

	int ans = 1;
	a[n] = b[n] = (int) 1e9 + 7;
	while (pa < n || pb < n)
	{
		if (a[pa] < b[pb] )
		{
			if (cnt < 0)
				smul(ans, -cnt);
			cnt++;
			pa++;
		}
		else
		{
			if (cnt > 0)
				smul(ans, cnt);
			cnt--;
			pb++;
		}
	}

	printf("%d\n", ans);

	return 0;
}

Submission Info

Submission Time
Task A - 1D Matching
User Merkurev
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1162 Byte
Status AC
Exec Time 40 ms
Memory 1024 KB

Compile Error

./Main.cpp: In function ‘int main(int, char**)’:
./Main.cpp:41:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
./Main.cpp:43:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i] );
                      ^
./Main.cpp:45:22: 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 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 25 ms 768 KB
001.txt AC 10 ms 384 KB
002.txt AC 14 ms 512 KB
003.txt AC 15 ms 512 KB
004.txt AC 39 ms 896 KB
005.txt AC 40 ms 1024 KB
006.txt AC 40 ms 1024 KB
007.txt AC 40 ms 1024 KB
008.txt AC 40 ms 1024 KB
009.txt AC 40 ms 1024 KB
010.txt AC 40 ms 1024 KB
011.txt AC 40 ms 1024 KB
example0.txt AC 3 ms 256 KB
example1.txt AC 3 ms 256 KB