Coding Test - cpp/Greedy
[백준 1946: 신입 사원] - C++
에드윈H
2021. 4. 12. 09:04
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
int total = 0;
cin >> total;
for (int k = 0; k < total; k++)
{
int n;
cin >> n;
vector<pair<int, int >> t(n);
for (int i = 0; i < n; i++)
{
cin >> t[i].first >> t[i].second;
}
sort(t.begin(), t.end());
int result = 0;
int min = 214000000;
for (int i = 0; i < n; i++)
{
if (min > t[i].second)
{
min = t[i].second;
result++;
}
}
cout << result << '\n';
}
return 0;
}