sgu 133 分类: sgu 2015-03-07 22:19 31人阅读 评论(0) 收藏
水题
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<iostream>
#include<algorithm>
#define INF 1<<30
const int MAXN = 16005;
struct node{int a,b;}mp[MAXN] = {0};
bool cmp(const node &x,const node &y)
{
return ((x.a < y.a) || (x.a == y.a && x.b < y.b));
}
int main()
{
int n , ans = 0 ,maxb = -INF;
#ifndef ONLINE_JUDGE
freopen("sgu133.in","r",stdin);
freopen("sgu133.out","w",stdout);
#endif
scanf("%d",&n);
for(int i = 1; i <= n ; i++) scanf("%d%d",&mp[i].a, &mp[i].b);
std::sort(mp + 1, mp + n + 1,cmp);
for(int i = 2; i <= n ; i++)
{
if(mp[i - 1].a < mp[i].a){maxb = std::max(maxb , mp[i - 1].b);}
if(mp[i].b < maxb) ans ++;
}
printf("%d",ans);
#ifndef ONLINE_JUDGE
fclose(stdin);
fclose(stdout);
#endif
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。