离散化

(说明后补)

cin >> n;
for (int i = 1;i <= n; ++i) {
cin >> B[i];
C[i] = B[i];
}
sort(C+1,C+n+1);
int m = unique(C+1,C+n+1) - C-1;


for (int i = 1;i <= n; ++i) {
B[i] = lower_bound(C+1,C+m+1,B[i]) - C;
}
for (int i = 1;i <= n; ++i) {
cout << C[B[i]] << " ";
}
cout << endl;

posted on 2018-11-28 03:32 Frank的成长之路 阅读(...) 评论(...) 编辑 收藏

导航

统计

公告