34272023-02-27 14:11:00AblablablaTalálkozáscpp11Time limit exceeded 8/55284ms5460 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> jelen(100002, 0);
    vector<int> elso(100002, 0);
    vector<int> utolso(100002, 0);
    int ind1, ind2, valasz;
    int legkesobb = 0;
    for(int i = 0; i < n; i++){
        int erk, megy;
        cin >> erk >> megy;
        for(int j = erk; j < megy; j++){
            jelen[j]++;
        }
        elso[erk]++;
        utolso[megy]++;
        if(megy > legkesobb){
            legkesobb = megy;
        }
    }

    int legkisebb = INT_MAX;
    for(int i = 1; i <= legkesobb; i++){
        int szamlalo = jelen[i];
        int j = i + 1;

        while(j < legkesobb && szamlalo < n/2 && j - i < legkisebb){
            szamlalo += elso[j];
            j++;
        }

        if(szamlalo >= n / 2 && j - i < legkisebb){
            legkisebb = j - 1 - i;
            ind1 = i + 1;
            ind2 = j - 1;
            valasz = szamlalo;
        }
    }

    cout << legkisebb << "\n" << ind1 << " " << ind2 << "\n";
}
SubtaskSumTestVerdictTimeMemory
base8/55
1Accepted0/04ms4076 KiB
2Time limit exceeded0/0256ms2440 KiB
3Wrong answer0/24ms4484 KiB
4Wrong answer0/24ms4716 KiB
5Wrong answer0/24ms4768 KiB
6Accepted2/212ms4912 KiB
7Wrong answer0/213ms5120 KiB
8Accepted3/310ms5460 KiB
9Accepted3/337ms5420 KiB
10Wrong answer0/337ms5452 KiB
11Time limit exceeded0/3275ms3560 KiB
12Time limit exceeded0/3232ms3508 KiB
13Time limit exceeded0/3261ms3788 KiB
14Time limit exceeded0/3236ms3812 KiB
15Time limit exceeded0/3259ms4092 KiB
16Time limit exceeded0/3275ms4492 KiB
17Time limit exceeded0/3277ms4456 KiB
18Time limit exceeded0/3256ms4604 KiB
19Time limit exceeded0/3284ms4632 KiB
20Time limit exceeded0/3259ms4756 KiB
21Time limit exceeded0/3268ms4820 KiB
22Time limit exceeded0/3275ms4840 KiB