测试了好多讨论里面的数据都能过,但是一个测试点也过不了
查看原帖
测试了好多讨论里面的数据都能过,但是一个测试点也过不了
446566
NMS1L1楼主2021/10/4 16:35
#include<bits/stdc++.h>
using namespace std;

int main() {
    int n, i, count;
    vector<int> v;
    cin >> n;

    for (int j = 0; j < n; ++j) {
        cin >> i;
        v.push_back(i);
    }

    sort(v.begin(), v.end());

    auto it = unique(v.begin(), v.end());
    auto end_unique = it;

    while (end_unique++ < v.end())
        ++count;
    cout << n - count << endl;
    for (auto beg = v.begin(); beg < it; ++beg) {
        if (beg != v.begin())
            cout << " ";
        cout << *beg;
    }
    return 0;
}
2021/10/4 16:35
加载中...