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

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

 

10871๋ฒˆ: X๋ณด๋‹ค ์ž‘์€ ์ˆ˜

์ฒซ์งธ ์ค„์— N๊ณผ X๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. (1 ≤ N, X ≤ 10,000) ๋‘˜์งธ ์ค„์— ์ˆ˜์—ด A๋ฅผ ์ด๋ฃจ๋Š” ์ •์ˆ˜ N๊ฐœ๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ์ฃผ์–ด์ง€๋Š” ์ •์ˆ˜๋Š” ๋ชจ๋‘ 1๋ณด๋‹ค ํฌ๊ฑฐ๋‚˜ ๊ฐ™๊ณ , 10,000๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™์€ ์ •์ˆ˜์ด๋‹ค.

www.acmicpc.net


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

๐ŸŽจ Go

package main

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

func main() {
	var n, x int
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	fmt.Fscanln(reader, &n, &x)
	defer writer.Flush()
    
	var sequence = make([]int, n)
	for i := range sequence {
		fmt.Fscanf(reader, "%d ", &sequence[i])
		if sequence[i] < x {
			fmt.Fprintf(writer, "%d ", sequence[i])
		}
	}
	fmt.Fprint(writer, "\n")
}

๐ŸŽจ Python3

import sys

n, x = map(int, sys.stdin.readline().split())
arr = list(map(int, sys.stdin.readline().split()))
for v in arr:
    if v < x:
        print(v, end=' ')
print()
728x90
๋Œ“๊ธ€