4416 | 2023-03-27 18:45:27 | balaaaazs | Zsonglőrködés | cpp14 | Wrong answer 0/100 | 207ms | 8616 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;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Wrong answer | 3ms | 1816 KiB | ||||
2 | Wrong answer | 3ms | 2056 KiB | ||||
subtask2 | 0/20 | ||||||
3 | Wrong answer | 4ms | 2296 KiB | ||||
4 | Wrong answer | 63ms | 3832 KiB | ||||
5 | Wrong answer | 155ms | 5944 KiB | ||||
6 | Wrong answer | 185ms | 6776 KiB | ||||
7 | Wrong answer | 207ms | 7588 KiB | ||||
8 | Wrong answer | 206ms | 7512 KiB | ||||
9 | Wrong answer | 206ms | 7764 KiB | ||||
10 | Wrong answer | 207ms | 7880 KiB | ||||
11 | Wrong answer | 206ms | 7832 KiB | ||||
subtask3 | 0/35 | ||||||
12 | Wrong answer | 3ms | 3360 KiB | ||||
13 | Wrong answer | 3ms | 3500 KiB | ||||
14 | Wrong answer | 3ms | 3364 KiB | ||||
15 | Wrong answer | 3ms | 3364 KiB | ||||
16 | Wrong answer | 3ms | 3608 KiB | ||||
17 | Wrong answer | 3ms | 3588 KiB | ||||
18 | Wrong answer | 3ms | 3580 KiB | ||||
19 | Wrong answer | 3ms | 3588 KiB | ||||
20 | Wrong answer | 3ms | 3684 KiB | ||||
subtask4 | 0/45 | ||||||
21 | Wrong answer | 4ms | 3832 KiB | ||||
22 | Wrong answer | 59ms | 5124 KiB | ||||
23 | Wrong answer | 155ms | 7344 KiB | ||||
24 | Wrong answer | 171ms | 7944 KiB | ||||
25 | Wrong answer | 204ms | 8468 KiB | ||||
26 | Wrong answer | 192ms | 8524 KiB | ||||
27 | Wrong answer | 204ms | 8616 KiB | ||||
28 | Wrong answer | 190ms | 8616 KiB | ||||
29 | Wrong answer | 206ms | 8476 KiB |