![nyoj_14:会场安排问题 nyoj_14:会场安排问题](https://image.shishitao.com:8440/aHR0cHM6Ly9ia3FzaW1nLmlrYWZhbi5jb20vdXBsb2FkL2NoYXRncHQtcy5wbmc%2FIQ%3D%3D.png?!?w=700&webp=1)
一道很经典的贪心问题
题目链接: http://acm.nyist.net/JudgeOnline/problem.php?pid=14
#include<iostream> #include<algorithm> using namespace std; struct met { int b,e; }a[]; bool comp(met x,met y) { return x.e<y.e; } int main() { int m,n,i,ans,t; cin>>m; while(m--) { ans=,t=; cin>>n; ;i<n;i++) cin>>a[i].b>>a[i].e; sort(a,a+n,comp); ;i<n;i++) { if(t<a[i].b) { ans++; t=a[i].e; } } cout<<ans<<endl; } }