44162023-03-27 18:45:27balaaaazsZsonglőrködéscpp14Wrong answer 0/100207ms8616 KiB
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct Talk {
    int start;
    int end;
};

bool compareTalks(const Talk& talk1, const Talk& talk2) {
    return talk1.start < talk2.start;
}

int main() {
    int n;
    cin >> n;

    vector<Talk> talks(n);
    for (int i = 0; i < n; i++) {
        cin >> talks[i].start >> talks[i].end;
    }

    sort(talks.begin(), talks.end(), compareTalks);

    vector<int> schedule(n);
    int daysNeeded = 1;
    int currentDay = talks[0].end;

    schedule[0] = currentDay;
    for (int i = 1; i < n; i++) {
        if (talks[i].start > currentDay) {
            // This talk cannot be held on the same day as the previous one
            currentDay = talks[i].end;
            daysNeeded++;
        } else {
            // This talk can be held on the same day as the previous one
            currentDay = max(currentDay, talks[i].end);
        }
        schedule[i] = currentDay;
    }

    cout << daysNeeded << endl;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer3ms1816 KiB
2Wrong answer3ms2056 KiB
subtask20/20
3Wrong answer4ms2296 KiB
4Wrong answer63ms3832 KiB
5Wrong answer155ms5944 KiB
6Wrong answer185ms6776 KiB
7Wrong answer207ms7588 KiB
8Wrong answer206ms7512 KiB
9Wrong answer206ms7764 KiB
10Wrong answer207ms7880 KiB
11Wrong answer206ms7832 KiB
subtask30/35
12Wrong answer3ms3360 KiB
13Wrong answer3ms3500 KiB
14Wrong answer3ms3364 KiB
15Wrong answer3ms3364 KiB
16Wrong answer3ms3608 KiB
17Wrong answer3ms3588 KiB
18Wrong answer3ms3580 KiB
19Wrong answer3ms3588 KiB
20Wrong answer3ms3684 KiB
subtask40/45
21Wrong answer4ms3832 KiB
22Wrong answer59ms5124 KiB
23Wrong answer155ms7344 KiB
24Wrong answer171ms7944 KiB
25Wrong answer204ms8468 KiB
26Wrong answer192ms8524 KiB
27Wrong answer204ms8616 KiB
28Wrong answer190ms8616 KiB
29Wrong answer206ms8476 KiB