34302023-02-27 14:43:47CsongiTalálkozáscpp17Wrong answer 0/5571ms5816 KiB
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct Guest {
    int arrival;
    int departure;
};

int main() {
    int n;
    cin >> n;
    vector<Guest> guests(n);
    for (int i = 0; i < n; i++) {
        cin >> guests[i].arrival >> guests[i].departure;
    }

    sort(guests.begin(), guests.end(), [](const Guest& a, const Guest& b) {
        return a.arrival < b.arrival;
    });

    int maxOverlap = 0;
    int overlap = 0;
    int start = guests[0].arrival;
    int end = guests[0].departure;
    int bestStart = start;
    int bestEnd = end;
    for (int i = 1; i < n; i++) {
        if (guests[i].arrival <= end) {
            overlap++;
            end = max(end, guests[i].departure);
        } else {
            if (overlap > maxOverlap) {
                maxOverlap = overlap;
                bestStart = start;
                bestEnd = end;
            }
            overlap = 0;
            start = guests[i].arrival;
            end = guests[i].departure;
        }
    }

    if (overlap > maxOverlap) {
        maxOverlap = overlap;
        bestStart = start;
        bestEnd = end;
    }

    cout << maxOverlap+1-2 << endl;
    cout << bestStart+8 << " " << bestEnd+1 << endl;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/55
1Accepted0/03ms1812 KiB
2Wrong answer0/068ms3408 KiB
3Wrong answer0/23ms2220 KiB
4Wrong answer0/23ms2364 KiB
5Wrong answer0/23ms2576 KiB
6Wrong answer0/23ms2788 KiB
7Wrong answer0/23ms2976 KiB
8Wrong answer0/33ms3068 KiB
9Wrong answer0/33ms3164 KiB
10Wrong answer0/33ms3288 KiB
11Wrong answer0/37ms3668 KiB
12Wrong answer0/38ms3792 KiB
13Wrong answer0/38ms3744 KiB
14Wrong answer0/314ms3860 KiB
15Wrong answer0/314ms4076 KiB
16Wrong answer0/314ms4164 KiB
17Wrong answer0/314ms4292 KiB
18Wrong answer0/321ms4500 KiB
19Wrong answer0/371ms5580 KiB
20Wrong answer0/364ms5448 KiB
21Wrong answer0/368ms5816 KiB
22Wrong answer0/368ms5796 KiB