ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป ๋ฌธ์ œ

 

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

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

www.acmicpc.net


โœ๐Ÿป ํ’€์ด

๐ŸŽจ Go

// https://www.acmicpc.net/problem/10867
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var n int
	fmt.Fscanln(reader, &n)

	var numbers = map[int]bool{}
	for i := 0; i < n; i++ {
		var key int
		fmt.Fscanf(reader, "%d ", &key)
		numbers[key] = true
	}

	keys := []int{}
	for key, _ := range numbers {
		keys = append(keys, key)
	}

	sort.Ints(keys)
	for _, key := range keys {
		fmt.Fprintf(writer, "%d ", key)
	}
	fmt.Fprintln(writer, "")
}

๐ŸŽจ Python3

# https://www.acmicpc.net/problem/10867
import sys

if __name__ == "__main__":
    n = int(sys.stdin.readline())
    numbers = set(map(int, sys.stdin.readline().split()))
    for i in sorted(numbers):
        print(i, end=" ")
    print()
728x90
๋Œ“๊ธ€