출처: https://cses.fi/problemset/task/1621
문제 설명
You are given a list of n integers, and your task is to calculate the number of distinct values in the list.
입력 양식
The first input line has an integer n: the number of values.
The second line has n integers x_1,x_2,…,x_n
출력
Print one integers: the number of distinct values.
입력 예
5
2 3 2 2 3
출력 예
2
제약조건
- 1 <= n <= 2x10^5
- 1 <= x_i <= 10^9
문제 풀이 내용
입력을 읽어 들여서 set에 입력하여 중복을 제거하고, set size를 출력한다.
프로그램 내용
더보기
...
set <long> distinct;
for (int idx=0; idx<nInput; ++idx)
distinct.insert(numbers);
cout << distinct.size() << endl;
Sorting and Searching ( link )
'CSES' 카테고리의 다른 글
CSES 2. Ferris Wheel (1090) (0) | 2019.09.25 |
---|---|
CSES 2. Apartments (1084) (0) | 2019.09.24 |
CSES 2. Sorting and Searching (0) | 2019.09.24 |
CSES 1. Chessboard and Queens (1624) (0) | 2019.09.23 |
CSES 1. Apple Division (1623) (0) | 2019.09.23 |