38962023-03-03 19:16:41horvathabelTalálkozáscpp17Wrong answer 46/5574ms19584 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/2){
		if (v-k<mego.second-mego.first){
			mego.second=v;
			mego.first=k;
		}
		k++;
		most-=megy[k-1];

	}
	else{
		 v++;
		most+=jott[v];
		
	}
}
cout<<mego.second-mego.first+1<<endl;
cout<<mego.first<<" "<<mego.second; 
}
SubtaskSumTestVerdictTimeMemory
base46/55
1Accepted0/08ms17336 KiB
2Accepted0/074ms17668 KiB
3Wrong answer0/28ms18036 KiB
4Wrong answer0/28ms17980 KiB
5Wrong answer0/28ms18120 KiB
6Accepted2/28ms18184 KiB
7Accepted2/28ms18316 KiB
8Accepted3/38ms18412 KiB
9Accepted3/38ms18500 KiB
10Accepted3/38ms18756 KiB
11Accepted3/313ms18720 KiB
12Accepted3/314ms18808 KiB
13Accepted3/313ms18808 KiB
14Accepted3/318ms18808 KiB
15Accepted3/318ms18952 KiB
16Accepted3/318ms19156 KiB
17Accepted3/318ms19240 KiB
18Accepted3/327ms19168 KiB
19Wrong answer0/374ms19168 KiB
20Accepted3/368ms19424 KiB
21Accepted3/371ms19500 KiB
22Accepted3/372ms19584 KiB