提交时间:2024-03-02 09:04:51
运行 ID: 133756
#include <bits/stdc++.h> #define LYY_doesnt_have_m_ante long long using namespace std; pair<LYY_doesnt_have_m_ante,LYY_doesnt_have_m_ante> a[105]; bool cmp(pair<LYY_doesnt_have_m_ante,LYY_doesnt_have_m_ante> x,pair<LYY_doesnt_have_m_ante,LYY_doesnt_have_m_ante> y) { return x.second < y.second; } signed main() { LYY_doesnt_have_m_ante n; cin >> n; while (n) { for (LYY_doesnt_have_m_ante i = 1; i <= n; i++) cin >> a[i].first >> a[i].second; sort(a + 1,a + n + 1,cmp); LYY_doesnt_have_m_ante nowen = a[1].second,cnt = 1; for (LYY_doesnt_have_m_ante i = 2; i <= n; i++) { if (a[i].first >= nowen) cnt++,nowen = a[i].second; } printf("%lld\n",cnt); cin >> n; } return 0; }