首页 > 其他分享 >离散化

离散化

时间:2022-11-13 21:23:30浏览次数:40  
标签:std main int 离散 include 500005

#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int a[500005],b[500005],n;
int main() {
    scanf("%d",&n);
    for(int i = 1;i <= n;++ i) scanf("%d",&a[i]),b[i] = a[i];
    sort(b + 1,b + n + 1);
    int c = unique(b + 1,b + n + 1) - b - 1;
    for(int i = 1;i <= n;++ i) a[i] = lower_bound(b + 1,b + c + 1,a[i]) - b;
    return 0;
}

标签:std,main,int,离散,include,500005
From: https://www.cnblogs.com/eegg/p/16886980.html

相关文章