用个标准模板,可能代码量会少一点
include [HTML_REMOVED]
include [HTML_REMOVED]
include[HTML_REMOVED]
using namespace std;
int main()
{
int num;
cin >> num;
vector[HTML_REMOVED]> s;
for(int i = 0;i < num;i)
{
int temp1,temp2;
cin >> temp1 >> temp2;
pair[HTML_REMOVED] temp(temp1,temp2);
s.push_back(temp);
}
sort(s.begin(),s.end(),{return a.second < b.second;});
int sum = 0,temp = -2e9;
for(auto i:s)
{
if(temp < i.first)
{
temp = i.second;
sum ;
}
}
cout << sum;
}