35712023-03-01 08:40:52vááááTalálkozáscpp11Wrong answer 50/5524ms5868 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;
    int k = 0, v = 0, jk = 0, jv = 0, mint = 5675765;

    if(n > 2) {
        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 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;
                }
            }
        }
    }
    if(n == 1){
        cin >> bek;
        cin >> kik;
        mint = 0;
        jk = bek;
        jv = bek;
    }
    if (n==2) {
        cin >> bek;
        cin >> kik;
        int bek2, kik2;
        cin >> bek2;
        cin >> kik2;
        if(kik > bek2){
            jk = bek2;
            jv = bek2;
            mint = 0;
        }
        else {
            jk = kik;
            jv = bek2;
            mint = bek2-kik;
        }
    }

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

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/55
1Accepted0/04ms3376 KiB
2Accepted0/024ms3596 KiB
3Wrong answer0/23ms3672 KiB
4Accepted2/23ms3808 KiB
5Accepted2/23ms3920 KiB
6Accepted2/23ms4000 KiB
7Accepted2/23ms4132 KiB
8Accepted3/33ms4332 KiB
9Accepted3/33ms4544 KiB
10Accepted3/33ms4756 KiB
11Accepted3/34ms4972 KiB
12Accepted3/34ms5060 KiB
13Accepted3/34ms5188 KiB
14Accepted3/37ms5388 KiB
15Accepted3/37ms5436 KiB
16Accepted3/37ms5440 KiB
17Accepted3/37ms5444 KiB
18Accepted3/39ms5444 KiB
19Wrong answer0/324ms5568 KiB
20Accepted3/321ms5652 KiB
21Accepted3/324ms5784 KiB
22Accepted3/324ms5868 KiB