Submission #3513329


Source Code Expand

#include<bits/stdc++.h>
#define rint register int
#define rep(i,a,b) for (rint i=(a),_E=(b); i<=_E; ++i)
#define per(i,a,b) for (rint i=(a),_E=(b); i>=_E; --i)
#define REP(i,n) for (rint i=0,_E=(n); i<_E; ++i)
#define pb push_back
#define cmin(x,y) (y<x?x=y:0)
#define cmax(x,y) (y>x?x=y:0)
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

const int N = 100005;
const int mod = 1000000007;
int a[N], b[N], n, cur, ans = 1;

int main() {
	scanf("%d", &n);
	rep (i, 1, n) scanf("%d", &a[i]);
	rep (i, 1, n) scanf("%d", &b[i]);
	sort(a + 1, a + n + 1);
	sort(b + 1, b + n + 1);
	cur = 0;
	rep (i, 1, n) {
		while (cur < n && a[cur+1] < b[i]) ++ cur;
		if (cur > i) ans = 1ll * ans * (cur - i + 1) % mod;
	}
	swap(a, b);
	cur = 0;
	rep (i, 1, n) {
		while (cur < n && a[cur+1] < b[i]) ++ cur;
		if (cur > i) ans = 1ll * ans * (cur - i + 1) % mod;
	}
	printf("%d\n", ans);
	return 0;
}

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:19:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
./Main.cpp:20:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  rep (i, 1, n) scanf("%d", &a[i]);
                                  ^
./Main.cpp:21:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  rep (i, 1, n) 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 24 ms 1024 KB
001.txt AC 9 ms 1024 KB
002.txt AC 12 ms 1024 KB
003.txt AC 14 ms 1024 KB
004.txt AC 34 ms 1024 KB
005.txt AC 38 ms 1024 KB
006.txt AC 38 ms 1024 KB
007.txt AC 38 ms 1024 KB
008.txt AC 38 ms 1024 KB
009.txt AC 38 ms 1024 KB
010.txt AC 37 ms 1024 KB
011.txt AC 38 ms 1024 KB
example0.txt AC 2 ms 1024 KB
example1.txt AC 2 ms 1024 KB