220312026-01-14 13:21:05gkataTalálkozáscpp17Időlimit túllépés 21/55300ms1272 KiB
// talalkozas.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <queue>
#define ll long long

using namespace std;

vector<int>erk(100000);
vector<int>tav(100000);

ll i, n, a, b, mt = -1, hossz, fel, poz;
bool ok = false;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n;

    for (i = 1; i <= n; ++i)
    {
        cin >> a >> b;
        ++erk[a];
        ++tav[b];
        if (b > mt) mt = b;
    }

    for (i = 1; i <= mt; ++i)
    {
        erk[i] += erk[i - 1];
        tav[i] += tav[i - 1];
    }

    fel = n / 2 + n % 1;
    for (hossz = 1; hossz <= mt; ++hossz)
    {
        for (i = hossz; i <= mt; ++i)
        {
            if (erk[i] - tav[i - hossz] >= fel)
            {
                poz = i;
                ok = true;
                break;
            }
        }
        if (ok) break;
    }

    cout << hossz << endl << poz - hossz + 1 << " " << poz;
}

/*
6
1 5
2 3
5 9
7 8
10 15
10 18
*/
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
RészfeladatÖsszpontTesztVerdiktIdőMemória
base21/55
1Elfogadva0/02ms1076 KiB
2Időlimit túllépés0/0280ms1076 KiB
3Elfogadva2/22ms1076 KiB
4Hibás válasz0/22ms1272 KiB
5Hibás válasz0/21ms1076 KiB
6Elfogadva2/28ms1076 KiB
7Elfogadva2/28ms1216 KiB
8Elfogadva3/38ms1220 KiB
9Elfogadva3/330ms1216 KiB
10Elfogadva3/329ms1076 KiB
11Időlimit túllépés0/3300ms1076 KiB
12Időlimit túllépés0/3282ms1076 KiB
13Időlimit túllépés0/3284ms1076 KiB
14Időlimit túllépés0/3279ms1076 KiB
15Időlimit túllépés0/3282ms1096 KiB
16Időlimit túllépés0/3300ms1104 KiB
17Időlimit túllépés0/3300ms1076 KiB
18Időlimit túllépés0/3289ms1076 KiB
19Elfogadva3/324ms1076 KiB
20Elfogadva3/321ms1076 KiB
21Időlimit túllépés0/3300ms1076 KiB
22Időlimit túllépés0/3279ms1264 KiB