128282025-01-01 23:46:35BucsMateTalálkozáscpp17Wrong answer 41/5567ms1080 KiB
#include <iostream>

using namespace std;

int jon[100001] = {};
int megy[100001] = {};

int main()
{
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        int a, b;
        cin >> a >> b;
        jon[a]++;
        megy[b]++;
    }

    int index_1 = 1, index_2 = 1, goal = N/2 + N%2, currNr = 0, minTime = 9999999;
    currNr += jon[1];
    int indexStart, indexEnd;

    for(index_1 = 1; index_1 <= 100000; index_1++){
        while(currNr < goal && index_2 < 100000){
            index_2++;
            currNr += jon[index_2];
        }
        if(minTime > index_2 - index_1 && currNr >= goal){
            minTime = index_2 - index_1 + 1;
            indexStart = index_1;
            indexEnd = index_2;
        }
        currNr -= megy[index_1];
    }

    cout << minTime << endl;
    cout << indexStart << " " << indexEnd << endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base41/55
1Accepted0/01ms512 KiB
2Wrong answer0/064ms1080 KiB
3Wrong answer0/22ms320 KiB
4Partially correct1/22ms320 KiB
5Accepted2/21ms320 KiB
6Accepted2/21ms320 KiB
7Accepted2/22ms320 KiB
8Accepted3/31ms320 KiB
9Accepted3/32ms320 KiB
10Accepted3/31ms320 KiB
11Accepted3/34ms568 KiB
12Accepted3/37ms568 KiB
13Accepted3/37ms748 KiB
14Accepted3/313ms568 KiB
15Partially correct1/313ms768 KiB
16Accepted3/313ms792 KiB
17Partially correct1/313ms776 KiB
18Accepted3/320ms1044 KiB
19Wrong answer0/367ms688 KiB
20Accepted3/359ms320 KiB
21Partially correct1/364ms1080 KiB
22Partially correct1/364ms1080 KiB