Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <vector>
- #include <map>
- using namespace std;
- struct movie{
- int S, E;
- movie(){}
- movie(int a, int b) {
- S = a;
- E = b;
- }
- bool operator < (const movie &x) const {
- return E < x.E;
- }
- };
- int main()
- {
- ios_base::sync_with_stdio(false);
- int n;
- cin >> n;
- vector<movie> v;
- for(int i =0; i < n; ++i) {
- int a, b;
- cin >> a >> b;
- v.push_back(movie(a, b));
- }
- sort(v.begin(), v.end());
- int last_ending_time = v[0].E;
- int ret = 1;
- for(int i = 1; i < n; ++i) {
- if(last_ending_time <= v[i].S) {
- ++ret;
- last_ending_time = v[i].E;
- }
- }
- cout << ret << endl;
- return 0;
- }
- /*
- 10
- 404 882
- 690 974
- 201 255
- 800 933
- 525 819
- 457 601
- 461 978
- 832 932
- 699 804
- 795 860
- */
Advertisement
Add Comment
Please, Sign In to add comment