发官方的题解

liujunhao 2024-04-13 15:56:55 2024-04-13 15:57:21 4 返回题目

#include<bits/stdc++.h>

using namespace std;

int a[100010],b[100010];

int main(){

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

}

{{ vote && vote.total.up }}