UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#191711#3395. 简单计数caoanzheng100132ms3612kbC++954b2023-10-08 18:48:392023-10-08 22:05:50

answer

#include<bits/stdc++.h>
#define int long long
#define DEBUG(x) cerr<<#x<<'='<<x<<endl
using namespace std;
int a[100005],b[100005];
bool cmp(int a,int b)
{
	return a<b;
}
int ans[100005];
const int mod=1e9+7; 
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		cin>>b[i];
	}
	sort(a+1,a+1+n,cmp);
	sort(b+1,b+1+n,cmp);
	int i=1,j=1;
	for(i=1;i<=n;i++)
	{
		while(b[i]>=a[j]&&j<=n)
		{
			ans[i]=j;
			j++;
		}
		j--;
	}
	for(i=j+1;i<=n;i++)
	{
		ans[i]=n;
	}
	int ans1=1;
	for(i=1;i<=n;i++)
	{
		if(i!=1)
		{
			ans1*=ans[i]-i+1;
			ans1%=mod;
		}
		else
		{
			ans1*=ans[i];
			ans1%=mod;
		}
	}
	cout<<ans1%mod;
    //fclose(stdin);
    //fclose(stdout);
	return 0;
}
/*1 2 3 4
  2 2 4 4*/

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 0ms
memory: 1268kb

input:

7
4 3 1 7 6 2 5
7 4 5 5 7 6 6

output:

576

result:

ok single line: '576'

Test #2:

score: 10
Accepted
time: 0ms
memory: 1264kb

input:

8
1 8 4 6 7 2 3 5
5 8 2 6 6 6 5 5

output:

0

result:

ok single line: '0'

Test #3:

score: 10
Accepted
time: 0ms
memory: 1272kb

input:

9
4 6 5 8 3 2 9 7 1
7 9 4 8 7 7 9 6 3

output:

3456

result:

ok single line: '3456'

Test #4:

score: 10
Accepted
time: 0ms
memory: 1272kb

input:

10
7 4 2 1 5 6 8 10 3 9
10 5 5 8 4 3 10 8 8 10

output:

7776

result:

ok single line: '7776'

Test #5:

score: 10
Accepted
time: 0ms
memory: 1268kb

input:

20
14 8 15 2 18 16 1 20 17 12 5 9 7 6 4 19 10 13 11 3
16 19 10 15 11 16 19 16 4 20 20 18 16 15 16 18...

output:

249358159

result:

ok single line: '249358159'

Test #6:

score: 10
Accepted
time: 0ms
memory: 1296kb

input:

1000
113 586 790 610 535 443 933 288 701 980 992 625 656 585 803 712 729 679 646 749 667 418 965 412...

output:

581327908

result:

ok single line: '581327908'

Test #7:

score: 10
Accepted
time: 33ms
memory: 3588kb

input:

98798
95389 54170 43879 14722 11897 91651 42220 85671 93899 87543 43914 2310 62911 40262 80849 75940...

output:

1

result:

ok single line: '1'

Test #8:

score: 10
Accepted
time: 35ms
memory: 3604kb

input:

100000
19593 21193 31782 88129 99039 76289 6323 19598 94821 7558 93479 48303 60436 79271 54903 75059...

output:

1

result:

ok single line: '1'

Test #9:

score: 10
Accepted
time: 35ms
memory: 3608kb

input:

99999
75455 28891 5231 77222 45860 70561 38762 57848 30535 67049 91445 10270 84930 33973 77067 81367...

output:

589270557

result:

ok single line: '589270557'

Test #10:

score: 10
Accepted
time: 29ms
memory: 3612kb

input:

100000
35254 88518 967 2893 38942 35271 99946 50225 64870 6504 14839 37391 85806 81742 3061 66708 88...

output:

790195877

result:

ok single line: '790195877'

Extra Test:

score: 0
Extra Test Passed