返回题解分享
讨论 / 题解分享/ 帖子详情

map的查询 - 题解

用文档中给的代码总有一个测试点TLE,故自己写了一个,成功AC。

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n, t[1000100];
  
    cin >> n;

    for (int i = 0; i < n; i++)
        scanf("%d", &t[i]);
  
    sort(t, t + n);
    printf("%d", t[0]);

    for (int i = 1; i < n; i++)
        if (t[i] != t[i - 1])
            printf(" %d", t[i]);
    puts("");
}
0 回复 0 转发 0 喜欢 5 阅读
回复 (0)
默认 最新
暂无回复,快来抢沙发!