Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _USE_MATH_DEFINES
- #include <iostream>
- #include <conio.h>
- #include <string>
- #include <set>
- #include <map>
- #include <algorithm>
- #include <string>
- #include <math.h>
- #include <vector>
- #include <cmath>
- #include <sstream>
- using namespace std;
- struct time
- {
- long long end, start;
- };
- bool operator<(time p1, time p2)
- {
- if (p1.end == p2.end)
- return p1.start < p2.start;
- else
- return p1.end < p2.end;
- }
- int main()
- {
- vector<time> times;
- long long prom1, prom2, n, sc = 1;
- cin >> n;
- for (int i = 1; i <= n; i++)
- {
- time prom;
- cin >> prom1 >> prom2;
- prom.start = prom1;
- prom.end = prom2;
- times.push_back(prom);
- }
- sort(times.begin(), times.end());
- prom1 = times[0].end;
- for (int i = 1; i < n; i++)
- {
- if (prom1 < times[i].start)
- {
- prom1 = times[i].end;
- sc++;
- }
- }
- cout << sc;
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment