209162026-01-11 11:23:49BikficcTalálkozáscpp17Partially correct 54/5570ms1268 KiB
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, x, y;
    vector<int> jott(100002,0),ment(100002,0);

    int maxido=0;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin >> x >> y;
        jott[x]++;
        ment[y+1]++;
        maxido=max(maxido, y);
    }
    maxido++;
    for(int i=1; i<=maxido; i++)
    {
        jott[i]=jott[i-1]+jott[i];
        ment[i]=ment[i-1]+ment[i];
    }

    int lsz= ( n%2==0 ? n/2 : n/2+1);

    int start=1, stop=2;
    int okstart=0, okstop=maxido;
    while (stop <= maxido && start <= stop)
    {
        if(jott[stop]-ment[start]<lsz)
        {
            stop++;
        }
        else
        {
            if (stop-start<okstop-okstart)
            {
                okstop=stop;
                okstart=start;
            }
            start++;
        }
    }
    cout<<okstop-okstart+1<<endl<<okstart<<" "<<okstop;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base54/55
1Accepted0/01ms1076 KiB
2Accepted0/068ms1076 KiB
3Partially correct1/22ms1076 KiB
4Accepted2/22ms1076 KiB
5Accepted2/21ms1076 KiB
6Accepted2/22ms1076 KiB
7Accepted2/22ms1080 KiB
8Accepted3/31ms1080 KiB
9Accepted3/32ms1076 KiB
10Accepted3/32ms1076 KiB
11Accepted3/34ms1076 KiB
12Accepted3/38ms1268 KiB
13Accepted3/38ms1192 KiB
14Accepted3/313ms1124 KiB
15Accepted3/314ms1076 KiB
16Accepted3/313ms1076 KiB
17Accepted3/313ms1200 KiB
18Accepted3/321ms1200 KiB
19Accepted3/370ms1200 KiB
20Accepted3/361ms1200 KiB
21Accepted3/368ms1200 KiB
22Accepted3/370ms1076 KiB