离散化:

for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(b,b+n);
	int len=unique(b,b+n)-b;
	for(int i=0;i<n;i++){
		a[i]=lower_bound(b,b+len,a[i])-b;
	}