38972023-03-03 19:18:11horvathabelTalálkozáscpp17Wrong answer 50/5575ms20020 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){
		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
base50/55
1Accepted0/08ms17336 KiB
2Accepted0/071ms17540 KiB
3Wrong answer0/28ms17748 KiB
4Accepted2/28ms17960 KiB
5Accepted2/28ms18180 KiB
6Accepted2/28ms18516 KiB
7Accepted2/28ms18596 KiB
8Accepted3/38ms18688 KiB
9Accepted3/38ms18688 KiB
10Accepted3/38ms18940 KiB
11Accepted3/313ms18888 KiB
12Accepted3/314ms19220 KiB
13Accepted3/314ms19432 KiB
14Accepted3/319ms19516 KiB
15Accepted3/318ms19640 KiB
16Accepted3/319ms19600 KiB
17Accepted3/319ms19600 KiB
18Accepted3/328ms19728 KiB
19Wrong answer0/375ms19812 KiB
20Accepted3/365ms19732 KiB
21Accepted3/371ms19944 KiB
22Accepted3/372ms20020 KiB