๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Algorithm ๐Ÿง‘๐Ÿป‍๐Ÿ’ป/๋ฐฑ์ค€(BOJ)

[๋ฐฑ์ค€,c++] 10867๋ฒˆ - ์ค‘๋ณต ๋นผ๊ณ  ์ •๋ ฌํ•˜๊ธฐ

by dkswnkk 2021. 10. 25.
 

10867๋ฒˆ: ์ค‘๋ณต ๋นผ๊ณ  ์ •๋ ฌํ•˜๊ธฐ

์ฒซ์งธ ์ค„์— ์ˆ˜์˜ ๊ฐœ์ˆ˜ N (1 ≤ N ≤ 100,000)์ด ์ฃผ์–ด์ง„๋‹ค. ๋‘˜์งธ์—๋Š” ์ˆซ์ž๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ์ด ์ˆ˜๋Š” ์ ˆ๋Œ“๊ฐ’์ด 1,000๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™์€ ์ •์ˆ˜์ด๋‹ค.

www.acmicpc.net

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {

    ios_base::sync_with_stdio(false);

    int N;
    vector<int>v;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int number;
        cin >> number;
        if (!(find(v.begin(), v.end(), number) != v.end()))
            v.push_back(number);
    }
    sort(v.begin(), v.end());

    for (int i : v) {
        cout << i << " ";
    }
}

๋Œ“๊ธ€