ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ Go
// https://www.acmicpc.net/problem/10546
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
reader := bufio.NewReader(os.Stdin)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
var n int
fmt.Fscanln(reader, &n)
var runners = map[string]int{}
for i := 0; i < n; i++ {
var runner string
fmt.Fscanln(reader, &runner)
runners[runner]++
}
for i := 0; i < n-1; i++ {
var finished string
fmt.Fscanln(reader, &finished)
runners[finished]--
if runners[finished] == 0 {
delete(runners, finished)
}
}
for key := range runners {
fmt.Fprintln(writer, key)
}
}
๐จ Python3
# https://www.acmicpc.net/problem/10546
import sys
if __name__ == "__main__":
n = int(sys.stdin.readline())
runners = {}
for i in range(n):
runner = sys.stdin.readline().rstrip()
if runner in runners:
runners[runner] += 1
else:
runners[runner] = 1
for i in range(n-1):
finished = sys.stdin.readline().rstrip()
if runners[finished] == 1:
runners.pop(finished)
else:
runners[finished] -= 1
for i in runners.keys():
print(i)
728x90
'dev > algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ / 1802๋ฒ / ์ข ์ด ์ ๊ธฐ [Go][Python3] (0) | 2021.02.17 |
---|---|
BOJ / 2428๋ฒ / ํ์ [Go][Python3] (0) | 2021.02.16 |
BOJ / 2910๋ฒ / ๋น๋ ์ ๋ ฌ [Go][Python3] (0) | 2021.02.14 |
BOJ / 1822๋ฒ / ์ฐจ์งํฉ [Go][Python3] (0) | 2021.02.13 |
BOJ / 2670๋ฒ / ์ฐ์๋ถ๋ถ์ต๋๊ณฑ [Go][Python3] (0) | 2021.02.12 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
TAG
- ์๊ณ ๋ฆฌ์ฆ
- ํด์๋งต
- ๋ธ๋ฃจํธํฌ์ค
- ๋ฐฑ์ค
- dfs
- ์๊ฐ๊ต์ฒด
- ์๋ฐ
- ์คํ
- Macbook pro 2012 mid 13
- BFS
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- BOJ
- Algorithm
- AWS
- ํ
- ๋งฅ๋ถ
- dp
- ballet
- ๋ถํ ์ ๋ณต
- MongoDB
- ๋งฅ๋ถํ๋ก
- java
- ๋ชฝ๊ณ ๋๋น
- baekjoon
- python3
- ํ๋ก์ด๋์์ฌ
- ๋ฐ๋
- ์ด๋ถํ์
- go
- Golang
- Total
- Today
- Yesterday