131092025-01-06 15:57:37KissCsongor777Találkozáscpp17Time limit exceeded 1/55298ms1632 KiB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int n,a,b,m=0,l=0,f,mn=10000000;
    cin>>n;
    f=(n+1)/2;
    int v[100001]={0};
    vector<int> e,t;
    vector<int>::iterator c;
    for(int i=1; i<=n; i++)
    {
        cin>>a>>b;
        e.push_back(a); t.push_back(b);
        if(b>m)m=b;
        for(int j=a; j<=b; j++)v[j]++;
    }
    for(int i=0; i<n; i++)
    {
        if(v[t[i]]<f)
        {if(t[i]<e[n-1])
        {b=f-v[t[i]];
        c=lower_bound(e.begin(),e.end(),t[i]+1);
        //cout<<*c<<" ";
        b=distance(e.begin(),c)+b-1;
        //cout<<b<<" ";
        l=e[b]-t[i]+1;}}
        else l=1;
        if(l<=mn){mn=l; a=t[i];}
    }
    cout<<mn<<endl;
    cout<<a<<" "<<a+mn-1;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base1/55
1Accepted0/01ms748 KiB
2Time limit exceeded0/0279ms1632 KiB
3Partially correct1/21ms564 KiB
4Wrong answer0/21ms564 KiB
5Wrong answer0/21ms564 KiB
6Wrong answer0/21ms756 KiB
7Wrong answer0/21ms564 KiB
8Wrong answer0/31ms568 KiB
9Wrong answer0/31ms564 KiB
10Wrong answer0/31ms568 KiB
11Wrong answer0/36ms1012 KiB
12Wrong answer0/38ms956 KiB
13Wrong answer0/310ms872 KiB
14Wrong answer0/319ms1076 KiB
15Wrong answer0/319ms1076 KiB
16Wrong answer0/319ms984 KiB
17Wrong answer0/319ms828 KiB
18Runtime error0/341ms1076 KiB
19Time limit exceeded0/3286ms816 KiB
20Time limit exceeded0/3298ms808 KiB
21Time limit exceeded0/3293ms1632 KiB
22Time limit exceeded0/3284ms1632 KiB