ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ Go
// https://www.acmicpc.net/problem/1822
package main
import (
"bufio"
"fmt"
"os"
"sort"
)
func main() {
reader := bufio.NewReader(os.Stdin)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
var aCount, bCount int
fmt.Fscanln(reader, &aCount, &bCount)
var elements = map[int]bool{}
for i := 0; i < aCount; i++ {
var elem int
fmt.Fscanf(reader, "%d ", &elem)
elements[elem] = true
}
for i := 0; i < bCount; i++ {
var elem int
fmt.Fscanf(reader, "%d ", &elem)
delete(elements, elem)
}
fmt.Fprintln(writer, len(elements))
var elemArray []int
for key := range elements {
elemArray = append(elemArray, key)
}
sort.Ints(elemArray)
arrToStr := fmt.Sprint(elemArray)
fmt.Fprint(writer, arrToStr[1:len(arrToStr)-1])
}
๐จ Python3
# https://www.acmicpc.net/problem/1822
import sys
if __name__ == "__main__":
a_count, b_count = list(map(int, sys.stdin.readline().split()))
a = set(map(int, sys.stdin.readline().split()))
b = set(map(int, sys.stdin.readline().split()))
diff = a.difference(b)
result = sorted(list(diff))
if len(result) == 0:
print(0)
else:
print(len(result))
for i in result:
print("{} ".format(i), end='')
print()
728x90
'dev > algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ / 10546๋ฒ / ๋ฐฐ๋ถ๋ฅธ ๋ง๋ผํ ๋ [Go][Python3] (0) | 2021.02.15 |
---|---|
BOJ / 2910๋ฒ / ๋น๋ ์ ๋ ฌ [Go][Python3] (0) | 2021.02.14 |
BOJ / 2670๋ฒ / ์ฐ์๋ถ๋ถ์ต๋๊ณฑ [Go][Python3] (0) | 2021.02.12 |
BOJ / 1543๋ฒ / ๋ฌธ์ ๊ฒ์ [Go][Python3] (0) | 2021.02.11 |
BOJ / 1485๋ฒ / ์ ์ฌ๊ฐํ [Go][Python3] (0) | 2021.02.10 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
TAG
- MongoDB
- dfs
- java
- dp
- Golang
- ํ๋ก์ด๋์์ฌ
- ๋ชฝ๊ณ ๋๋น
- ์คํ
- Macbook pro 2012 mid 13
- ballet
- go
- ํ
- BOJ
- AWS
- ๋ธ๋ฃจํธํฌ์ค
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- ํด์๋งต
- ๋ถํ ์ ๋ณต
- BFS
- baekjoon
- ๋ฐ๋
- ์ด๋ถํ์
- ๋ฐฑ์ค
- ๋งฅ๋ถ
- ์๊ณ ๋ฆฌ์ฆ
- Algorithm
- ๋งฅ๋ถํ๋ก
- ์๊ฐ๊ต์ฒด
- ์๋ฐ
- python3
- Total
- Today
- Yesterday