69152023-12-19 17:41:22Huni136Találkozáscpp17Accepted 55/5570ms5484 KiB
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> jon(100001,0),megy(100001,0);
    int x,y,maxi=0;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        jon[x]++;
        megy[y]++;
        maxi=max(maxi,y);
    }

    int v=100000001,k=0,veg=0,kezd=1,most=0;
    
    while(kezd<=maxi && veg<=maxi)
    {
        //most+=jon[i];
        if(most<(n+1)/2)
        {
            veg++;
            most+=jon[veg];
        }
        else
        {
            //cout<<kezd<<" "<<veg<<endl;
            if(veg-kezd<v-k)
            {
                v=veg;
                k=kezd;
            }
            if(v-k==0)
            {
                cout<<1<<endl<<v<<" "<<v;
                return 0;
            }
            most-=megy[kezd];
            kezd++;
           // cout<<most<<endl;
        }
    }
    
    cout<<v-k+1<<endl;
    cout<<k<<" "<<v;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base55/55
1Accepted0/03ms3168 KiB
2Accepted0/067ms3380 KiB
3Accepted2/23ms3588 KiB
4Accepted2/23ms3800 KiB
5Accepted2/23ms4012 KiB
6Accepted2/23ms4076 KiB
7Accepted2/23ms4204 KiB
8Accepted3/33ms4416 KiB
9Accepted3/33ms4500 KiB
10Accepted3/34ms4720 KiB
11Accepted3/37ms4804 KiB
12Accepted3/38ms4844 KiB
13Accepted3/39ms5204 KiB
14Accepted3/314ms5008 KiB
15Accepted3/314ms5008 KiB
16Accepted3/314ms5012 KiB
17Accepted3/314ms5284 KiB
18Accepted3/323ms5260 KiB
19Accepted3/370ms5364 KiB
20Accepted3/361ms5360 KiB
21Accepted3/367ms5452 KiB
22Accepted3/367ms5484 KiB