67232023-12-18 09:56:47szabelrTalálkozáscpp17Wrong answer 1/55300ms8660 KiB
#include <iostream>

using namespace std;

int main()
{
    int n,erk,z,tav,mini=100000,maxi=0,emberek=0;
    cin>>n;
    int tomb[100001] {0};
    int tomb1[100001] {0};
    for(int i=1; i<=n; i++)
    {
        cin>>erk>>tav;
        for(int y=erk; y<=tav; y++){
            tomb[y]++;
        }
        if (tav>maxi)
            maxi=tav;
    }
    for(int i=1; i<=maxi; i++)
    {
        z=i;
        emberek=0;
        while(emberek<(n/2) and z<=maxi)
        {
            emberek=emberek+tomb[z];
            z++;
        }
        if(emberek>=(n/2))
        {
            tomb1[i]=z;
            if((z-i)<mini)
                mini=z-i;
        }
    }
    cout<<mini<<endl;
    for(int i=1; i<=maxi; i++)
    {
        if(tomb1[i]-i-1==mini)
        {
            cout<<i<<" "<<tomb1[i];
            break;
        }
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base1/55
1Wrong answer0/04ms3696 KiB
2Time limit exceeded0/0300ms3352 KiB
3Partially correct1/23ms5184 KiB
4Wrong answer0/23ms5224 KiB
5Wrong answer0/23ms5500 KiB
6Wrong answer0/24ms5688 KiB
7Wrong answer0/24ms5740 KiB
8Wrong answer0/34ms5828 KiB
9Wrong answer0/34ms5724 KiB
10Wrong answer0/34ms5852 KiB
11Wrong answer0/313ms6100 KiB
12Wrong answer0/316ms6072 KiB
13Wrong answer0/314ms6300 KiB
14Wrong answer0/323ms6528 KiB
15Wrong answer0/324ms6888 KiB
16Wrong answer0/323ms7020 KiB
17Wrong answer0/323ms7364 KiB
18Wrong answer0/346ms7856 KiB
19Time limit exceeded0/3250ms6260 KiB
20Time limit exceeded0/3254ms6568 KiB
21Time limit exceeded0/3266ms7516 KiB
22Time limit exceeded0/3254ms8660 KiB