Untitled
unknown
c_cpp
a year ago
376 B
4
Indexable
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; pair<int, int> p[n]; for(int i = 0; i < n; i++) { cin >> p[i].second >> p[i].first; } sort(p, p + n); int t = p[0].first; int res = 1; for(int i = 1; i < n; i++) { if(p[i].second >= t) { res++; t = p[i].first; } } cout << res << endl; return 0; }
Editor is loading...
Leave a Comment