sort函数用法:
#include<algorithm>
using namespace std;
sort(a,a+len;cmp) //a-->数组名, len-->数组长度
C/C++:
#include<stdio.h>
#include<algorithm>
using namespace std;
typedef struct
{
int x;
int y;
}pi;
pi p[]; int number(int n)
{
int t, cnt = ;
for(int i = ; i < n; ++i)
{
if(p[i].y)
{
++cnt;
t = p[i].y;
p[i].y = ;
for(int j = i + ; j < n ;++j)
{
if(p[j].y >= t)
{
t = p[j].y;
p[j].y= ;
}
}
}
}
return cnt;
} int cmp( pi a,pi b)
{
if(a.x>b.x)
return ;
if(a.x==b.x)
return a.y<b.y;
return ;
}
int main()
{
// freopen("250.txt","r",stdin);
int t,n,i;
int sum=;
scanf("%d",&t);
while(t--)
{
sum=;
scanf("%d",&n);
for(i=;i<n;i++)
scanf("%d%d",&p[i].x,&p[i].y);
sort(p,p+n,cmp);
// for(i=0;i<n;i++)
// printf("%d %d\n",p[i].x,p[i].y); printf("%d\n",number(n));
}
return ;
}
java: