16712022-12-01 15:02:01kovacs.peter.18fTalálkozáscpp11Wrong answer 41/5534ms5428 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 = 0, 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 <= 100000 && 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/034ms3484 KiB
3Wrong answer0/23ms2236 KiB
4Partially correct1/22ms2456 KiB
5Accepted2/22ms2436 KiB
6Accepted2/23ms2672 KiB
7Accepted2/23ms2772 KiB
8Accepted3/33ms2996 KiB
9Accepted3/33ms3232 KiB
10Accepted3/33ms3288 KiB
11Accepted3/34ms3304 KiB
12Accepted3/34ms3636 KiB
13Accepted3/34ms3532 KiB
14Accepted3/38ms3872 KiB
15Partially correct1/38ms3924 KiB
16Accepted3/38ms3924 KiB
17Partially correct1/38ms3924 KiB
18Accepted3/312ms4028 KiB
19Wrong answer0/326ms5080 KiB
20Accepted3/324ms5208 KiB
21Partially correct1/334ms5196 KiB
22Partially correct1/334ms5428 KiB