QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#130989#5378. 匹配问题Sorting0 2ms5532kbC++598b2023-07-26 02:01:342023-07-26 02:01:36

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-26 02:01:36]
  • 评测
  • 测评结果:0
  • 用时:2ms
  • 内存:5532kb
  • [2023-07-26 02:01:34]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n;
int la,lb;
int a[500001],b[500001];
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	cin >> n >> la >> lb;
	for(int i=1; i<=n ;i++) cin >> a[i];
	for(int i=1; i<=n ;i++) cin >> b[i];
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	int ans=0;
	for(int i=n; i>=1 ;i--){
		int x=i;
		while(x>=1 && b[x]>a[i]+lb) x--;
		if(x>=1 && b[x]>a[i]){
			bool ok=true;
			for(int j=x; j<i ;j++){
				if(b[j+1]>a[j]+la) ok=false;
			}
			if(ok){
				ans++;
				for(int j=x; j<i ;j++) swap(b[j],b[j+1]);
			}
		}
	}
	cout << ans << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 5532kb

input:

2 2 1
1 1
1 1

output:

0

result:

wrong answer 1st lines differ - expected: '2', found: '0'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Time Limit Exceeded

Test #100:

score: 0
Time Limit Exceeded

input:

500000 500000 10
200184 74991 71203 334998 316800 34483 120570 301054 331108 232072 189788 397143 490296 56807 361700 88818 42376 460305 371750 450351 338384 429789 426045 445029 152316 408919 188124 144966 457495 475025 225370 260510 383159 495247 54319 246245 240728 372033 439599 119720 449020 451...

output:


result:


Subtask #5:

score: 0
Skipped

Dependency #1:

0%