81352024-01-12 14:17:54AGergoTalálkozáscpp17Runtime error 36/5570ms5556 KiB
#include <bits/stdc++.h>

using namespace std;

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

    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+1]++;
        if(temp > last)
        {
            last = temp+1;
        }
    }
    int H = erkezes[0],v=0,k=0;

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

    while(k!= last)
    {
        if(H < cel)
        {
            //cout << H <<" Emberek: " << erkezes[v] << " " << tavoz[k]<<" v: " << v <<" k: "<<k <<endl;
            v++;
            H += erkezes[v];
            if(v > last+1)
            {
                //cout << "V>last+1"<<endl;
                break;
            }
        }
        else
        {

            k++;

            H -= tavoz[k];

             //cout << H <<" Emberek: " << erkezes[v] << " " << tavoz[k]<<" v: " << v <<" k: "<<k <<endl;

            if(H < cel && v-k+1 < endP-startP)
            {
                //cout<< endP << ":" << startP <<endl;
                startP = k-1;
                endP = v;
                //cout<< endP << ":" << startP <<endl;
            }
        }
    }

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

}
SubtaskSumTestVerdictTimeMemory
base36/55
1Runtime error0/04ms3464 KiB
2Accepted0/068ms3416 KiB
3Runtime error0/24ms3912 KiB
4Accepted2/23ms3692 KiB
5Accepted2/23ms3728 KiB
6Runtime error0/24ms4152 KiB
7Accepted2/24ms4064 KiB
8Accepted3/33ms4280 KiB
9Accepted3/34ms4360 KiB
10Accepted3/33ms4360 KiB
11Accepted3/37ms4640 KiB
12Accepted3/38ms4636 KiB
13Accepted3/38ms4848 KiB
14Runtime error0/314ms5156 KiB
15Runtime error0/316ms5304 KiB
16Accepted3/314ms5100 KiB
17Accepted3/314ms5176 KiB
18Accepted3/323ms5096 KiB
19Wrong answer0/370ms5096 KiB
20Accepted3/363ms5224 KiB
21Runtime error0/368ms5556 KiB
22Runtime error0/368ms5420 KiB