16692022-12-01 15:01:05kovacs.peter.18fTalálkozáscpp11Wrong answer 41/5535ms5624 KiB
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    cin.sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;
    vector<int> arriveS(N), leaveS(N);
    for (int i = 0; i < N; i++) {
        cin >> arriveS[i] >> leaveS[i];
    }
    sort(arriveS.begin(), arriveS.end());
    sort(leaveS.begin(), leaveS.end());
    int min_begin = -1, min_end, count = 0, a_index = 0, l_index = 0;
    for (int l = 0, r = 0; l <= 100000; l++) {
        // r: időintervallum vége (nyílt)
        while (r < 100001 && count * 2 < N) {
            while (a_index < N && arriveS[a_index] <= r) {
                ++a_index;
                ++count;
            }
            ++r;
        }
        // l: időintervallum eleje (zárt)
        if (count * 2 >= N && (min_begin == -1 || min_end - min_begin >= r - l)) {
            min_begin = l;
            min_end = r;
        }
        while (l_index < N && leaveS[l_index] <= l) {
            ++l_index;
            --count;
        }
    }
    cout << min_end - min_begin << '\n' << min_begin << " " << min_end - 1 << '\n';
}
SubtaskSumTestVerdictTimeMemory
base41/55
1Accepted0/03ms1828 KiB
2Wrong answer0/035ms3480 KiB
3Wrong answer0/22ms2092 KiB
4Partially correct1/22ms2120 KiB
5Accepted2/22ms2324 KiB
6Accepted2/22ms2404 KiB
7Accepted2/22ms2528 KiB
8Accepted3/32ms2764 KiB
9Accepted3/32ms2960 KiB
10Accepted3/32ms3012 KiB
11Accepted3/34ms3416 KiB
12Accepted3/34ms3648 KiB
13Accepted3/34ms3596 KiB
14Accepted3/38ms3824 KiB
15Partially correct1/38ms3884 KiB
16Accepted3/38ms4012 KiB
17Partially correct1/38ms4216 KiB
18Accepted3/312ms4420 KiB
19Wrong answer0/327ms5624 KiB
20Accepted3/325ms5568 KiB
21Partially correct1/335ms5572 KiB
22Partially correct1/335ms5572 KiB