35122023-02-28 14:40:48vááááTalálkozáscpp11Wrong answer 50/5523ms6236 KiB
#include <iostream>
#include <string>
#include <climits>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    double n;
    cin >> n;

    int be[100001] = {};
    int ki[100001] = {};
    string a;
    int bek;
    int kik;
    int max = 0;

    for (int i = 0; i < n; i++)
    {
        cin >> bek;
        cin >> kik;

        if (be[bek] == 0)
            be[bek] = 1;
        else
            be[bek]++;

        if (ki[kik] == 0)
            ki[kik] = 1;
        else
            ki[kik]++;

        if (max < kik)
            max = kik + 1;
    }

    be[0] = 0;
    ki[0] = 0;

    int k = 0, v = 0, jk = 0, jv = 0, mint = 5675765;
    int bent = 0;
    int benttemp = 0;
    bool volt = false;

    while (v < max - 1)
    {
        v++;
        bent += be[v];
        int j = 2;

        while (bent >= n / 2)
        {
            volt = true;
            k++;
            benttemp = bent;
            bent -= ki[k - 1];
        }

        if (volt)
        {
            k--;
            volt = false;
            bent = benttemp;

            if (mint > v - k)
            {
                jk = k;
                jv = v;
                mint = v - k;
            }
        }
    }

    cout << mint + 1 << endl;
    cout << jk << " " << jv << endl;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/55
1Accepted0/04ms3376 KiB
2Accepted0/023ms3568 KiB
3Wrong answer0/23ms3780 KiB
4Accepted2/23ms3984 KiB
5Accepted2/23ms4200 KiB
6Accepted2/23ms4420 KiB
7Accepted2/23ms4632 KiB
8Accepted3/33ms4840 KiB
9Accepted3/33ms5056 KiB
10Accepted3/33ms5136 KiB
11Accepted3/34ms5252 KiB
12Accepted3/34ms5336 KiB
13Accepted3/34ms5336 KiB
14Accepted3/37ms5236 KiB
15Accepted3/37ms5496 KiB
16Accepted3/37ms5576 KiB
17Accepted3/37ms5800 KiB
18Accepted3/39ms6004 KiB
19Wrong answer0/323ms6236 KiB
20Accepted3/321ms6192 KiB
21Accepted3/323ms6200 KiB
22Accepted3/323ms6096 KiB