-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
34 lines (32 loc) · 765 Bytes
/
Copy pathmain.cpp
File metadata and controls
34 lines (32 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n;
struct Meeting {
int begin, end;
};
bool comp(const Meeting &a, const Meeting &b) {
if(a.end == b.end) return a.begin < b.begin;
else return a.end < b.end;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(); cout.tie();
cin >> n;
vector<Meeting> meetings(n);
for(int i=0; i<n; i++) {
cin >> meetings[i].begin >> meetings[i].end;
}
sort(meetings.begin(), meetings.end(), comp);
int current = 0;
int answer = 0;
for(int i=0; i<n; i++) {
if(current <= meetings[i].begin) {
current = meetings[i].end;
answer++;
}
}
cout << answer << '\n';
return 0;
}