Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int N = 1e6 + 5;
- int maxx[N];
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- cerr.tie(nullptr);
- int n;
- cin >> n;
- vector<pair<int, int>> v(n);
- for (auto& e : v) {
- cin >> e.first >> e.second;
- }
- sort(v.begin(), v.end());
- maxx[n-2] = v[n-1].second;
- for (int i = n-2; i>=1; i--) {
- maxx[i-1] = max(maxx[i], v[i].second);
- }
- int sol = 1;
- for (int i = 0; i<n-1; i++) {
- if (v[i].second > maxx[i]) {
- sol++;
- }
- }
- cout << sol << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment