题目: TOJ 1469
贪心
#include <iostream>
using namespace std;
class Stick{
public:
int h;
int w;
bool operator<(const Stick st) const{
if(h==st.h) return w<st.w;
return h<st.h;
};
};
Stick st[5000];
int main(){
int t,n,cnt;
cin>>t;
while(t--){
cin>>n;
for(int i=0;i<n;i++)
cin>>st[i].h>>st[i].w;
sort(st,st+n);
cnt=0;
for(int i=0;i<n;i++)
if(st[i].h!=-1){
cnt++;
for(int j=i+1;j<n;j++){
if(st[j].h!=-1 && st[i].w<=st[j].w)
st[j].h=-1;
}
}
cout<<cnt<<endl;
}
return 0;
}