38982023-03-03 19:21:03horvathabelTalálkozáscpp17Wrong answer 8/5575ms20184 KiB
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n;
	cin>>n;
	vector<int> jott(1000001); 
	vector<int> megy(1000001); 
	int mx=0;
	for (int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		jott[x]++;
		megy[y]++;
		mx=max(y,mx);
	}
int v=1,k=0;
int most=jott[1]; 
pair<int, int> mego={0,1000001};
while (v<mx && k<mx){
	
	if (most>=(n+1)/2 && k<v){
		
		k++;
		most-=megy[k-1];

	}
	else{
		 v++;
		most+=jott[v];
		
	}
	if (v-k<mego.second-mego.first){
			mego.second=v;
			mego.first=k;
		}
	
}
cout<<mego.second-mego.first+1<<endl;
cout<<mego.first<<" "<<mego.second; 
}
SubtaskSumTestVerdictTimeMemory
base8/55
1Wrong answer0/08ms17332 KiB
2Wrong answer0/071ms17820 KiB
3Accepted2/28ms17788 KiB
4Wrong answer0/28ms17892 KiB
5Wrong answer0/28ms17944 KiB
6Wrong answer0/28ms18272 KiB
7Wrong answer0/28ms18488 KiB
8Wrong answer0/38ms18568 KiB
9Wrong answer0/38ms18824 KiB
10Wrong answer0/38ms19160 KiB
11Wrong answer0/312ms19112 KiB
12Wrong answer0/314ms19204 KiB
13Wrong answer0/314ms19204 KiB
14Wrong answer0/320ms19460 KiB
15Wrong answer0/320ms19412 KiB
16Wrong answer0/319ms19540 KiB
17Wrong answer0/319ms19628 KiB
18Wrong answer0/328ms19628 KiB
19Accepted3/375ms19708 KiB
20Accepted3/365ms19964 KiB
21Wrong answer0/371ms20184 KiB
22Wrong answer0/372ms20064 KiB