80632024-01-12 11:45:21AGergoTalálkozáscpp17Runtime error 0/5570ms6248 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int vendszam,temp,last,startP,endP;

    cin >> vendszam;

    vector<int> erkezes(100002,0);
    vector<int> tavoz(100002,0);

    for(int i = 0; i < vendszam;i++)
    {
        cin >> temp;
        erkezes[temp]++;
        cin >> temp;
        tavoz[temp]++;
        if(temp > last)
        {
            last = temp;
        }
    }
    int H = erkezes[0],v=0,k=0;

    int cel = vendszam/2;
    if(vendszam%2==1)
    {
        cel++;
    }

    while(k!= last)
    {
        if(H < cel)
        {
            v++;
            H += erkezes[v];
            if(v > last+1)
            {
                break;
            }
        }
        else
        {
            k++;
            H -= tavoz[k];
            if(H < cel)
            {
                startP = k-1;
                endP = v;
            }
        }
    }

    cout << endP-startP+1 << endl << startP << " " << endP;

}
SubtaskSumTestVerdictTimeMemory
base0/55
1Runtime error0/04ms3644 KiB
2Runtime error0/068ms3804 KiB
3Wrong answer0/23ms3748 KiB
4Wrong answer0/23ms3840 KiB
5Wrong answer0/23ms4052 KiB
6Runtime error0/24ms4556 KiB
7Runtime error0/24ms4792 KiB
8Runtime error0/34ms4960 KiB
9Wrong answer0/33ms4740 KiB
10Wrong answer0/34ms4908 KiB
11Runtime error0/37ms5284 KiB
12Runtime error0/38ms5540 KiB
13Wrong answer0/38ms5328 KiB
14Wrong answer0/314ms5348 KiB
15Wrong answer0/314ms5568 KiB
16Runtime error0/314ms5832 KiB
17Wrong answer0/314ms5440 KiB
18Runtime error0/323ms5864 KiB
19Runtime error0/370ms6072 KiB
20Wrong answer0/361ms5856 KiB
21Runtime error0/367ms6248 KiB
22Wrong answer0/367ms5856 KiB