不知道为什么,之前都是while(scanf()!=EOF)可以,而这次就不行
解法:排序,维护r的最值即可...其实是不需要priority_queue的...
ps:刚把今天codeforces的题扫了一眼...然后就没有然后了...@_@ ,我太弱了...弱了...
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
struct seg
{
int l,r;
}s[16005];
bool cmp(const seg &a,const seg &b)
{
return a.l<b.l;
}
int main()
{
int n,i,ans;
priority_queue<int,vector<int>,less<int> > q;
scanf("%d",&n);
// while(scanf("%d",&n)!=EOF)
// {
for(i=0;i<n;++i)
{
scanf("%d %d",&s[i].l,&s[i].r);
}
while(!q.empty())
q.pop();
ans=0;
sort(s,s+n,cmp);
q.push(s[0].r);
for(i=1;i<n;++i)
{
if(q.top()>s[i].r)
ans++;
q.push(s[i].r);
}
cout<<ans<<endl;
// printf("%d\n",ans);
// }
return 0;
}