1 solutions
-
-1
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; struct war { int l, r; } a[N]; bool cmp(war x, war y) { return x.r < y.r; } int main() { int n, m; cin >> n >> m; for (int i = 0; i < m; ++i) cin >> a[i].l >> a[i].r; sort(a, a + m, cmp); int ans = 0; int last = -1; for (int i = 0; i < m; ++i) { if (last < a[i].l) { ans++; last = a[i].r - 1; } } cout << ans << endl; return 0; }
- 1
Information
- ID
- 24349
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 9
- Tags
- (None)
- # Submissions
- 750
- Accepted
- 62
- Uploaded By