34722023-02-28 11:38:16horvathabelTalálkozáscpp17Time limit exceeded 8/55300ms4720 KiB
#include <bits/stdc++.h>
#include <climits>
using namespace std;

int main() {
	int n; 
	cin>>n;
	vector<pair<int,int>> veg;
	for (int i=0;i<n;i++){
		int x,y;
		cin>>x>>y; 
		veg.push_back(make_pair(y,x));
	}
	sort(veg.begin(), veg.end());
	int ans=1000001; 
	pair<int , int> mego; 
	for (int i=0; i<n-n/2+1;i++){
		int k=-1,v=1000001;
		for (int j=i; j<i+n/2;j++){
			k=max(k,veg[j].second);
			v=min(v,veg[j].first);
			

		}
		if (k-v<ans){
				ans=k-v;
				mego={k,v};
			}
	}
	cout<<ans+1<<endl<<mego.second<<" "<<mego.first;
}
SubtaskSumTestVerdictTimeMemory
base8/55
1Accepted0/03ms1812 KiB
2Time limit exceeded0/0300ms2432 KiB
3Wrong answer0/23ms2344 KiB
4Wrong answer0/23ms2552 KiB
5Wrong answer0/23ms2772 KiB
6Accepted2/23ms2860 KiB
7Wrong answer0/23ms2984 KiB
8Accepted3/33ms3064 KiB
9Accepted3/33ms3312 KiB
10Wrong answer0/33ms3560 KiB
11Wrong answer0/314ms3520 KiB
12Wrong answer0/328ms3684 KiB
13Wrong answer0/329ms3976 KiB
14Wrong answer0/394ms4324 KiB
15Wrong answer0/397ms4444 KiB
16Wrong answer0/387ms4652 KiB
17Wrong answer0/392ms4656 KiB
18Time limit exceeded0/3238ms4712 KiB
19Time limit exceeded0/3268ms4560 KiB
20Time limit exceeded0/3272ms4640 KiB
21Time limit exceeded0/3287ms4568 KiB
22Time limit exceeded0/3246ms4720 KiB