69142023-12-19 17:36:35Huni136Találkozáscpp17Wrong answer 50/5575ms5920 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;
            }
            most-=megy[kezd];
            kezd++;
           // cout<<most<<endl;
        }
    }
    if(veg-kezd<v-k)
            {
                v=veg;
                k=kezd;
            }
    cout<<v-k+1<<endl;
    cout<<k<<" "<<v;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/55
1Accepted0/04ms3168 KiB
2Accepted0/071ms3360 KiB
3Wrong answer0/23ms3604 KiB
4Accepted2/23ms3676 KiB
5Accepted2/23ms3648 KiB
6Accepted2/24ms3804 KiB
7Accepted2/24ms4004 KiB
8Accepted3/34ms4364 KiB
9Accepted3/34ms4364 KiB
10Accepted3/33ms4508 KiB
11Accepted3/37ms4592 KiB
12Accepted3/39ms4592 KiB
13Accepted3/39ms4588 KiB
14Accepted3/316ms4752 KiB
15Accepted3/316ms4964 KiB
16Accepted3/317ms5184 KiB
17Accepted3/314ms5388 KiB
18Accepted3/324ms5748 KiB
19Wrong answer0/375ms5708 KiB
20Accepted3/365ms5744 KiB
21Accepted3/372ms5832 KiB
22Accepted3/371ms5920 KiB