https://www.acmicpc.net/problem/1946
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
const int MAX = 100000;
pair<int, int> e[MAX];
int n;
// 신입사원
int solution(){
int answer = 1;
sort(e, e+n);
int mini = e[0].second;
for(int i=1;i<n;i++){
if(e[i].second < mini){
answer++;
mini = e[i].second;
}
if(mini == 1)
return answer;
}
return answer;
}
#include<iostream>
#include<cstdio>
using namespace std;
int T;
int N;
int v[100001];
int main(void)
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> T;
for (int t = 0; t < T; t++)
{
cin >> N;
for (int n = 0; n < N; n++)
{
int n1, n2;
cin >> n1 >> n2;
v[n1] = n2;
}
int tmp = v[1];
int cnt = 1;
for (int n = 2; n <= N; n++)
{
if (tmp >= v[n])
{
tmp = v[n];
cnt++;
}
}
cout << cnt << "\n";
}
return 0;
}