ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ Go
// https://www.acmicpc.net/problem/7785
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 workers = map[string]int{}
for i := 0; i < n; i++ {
var name, commute string
fmt.Fscanln(reader, &name, &commute)
if commute == "enter" {
workers[name] = 1
} else if commute == "leave" {
delete(workers, name)
}
}
var keys = []string{}
for key, _ := range workers {
keys = append(keys, key)
}
sort.Slice(keys, func(i, j int) bool {
return keys[i] > keys[j]
})
for _, key := range keys {
fmt.Fprintln(writer, key)
}
}
๐จ Python3
# https://www.acmicpc.net/problem/7785
import sys
if __name__ == "__main__":
n = int(sys.stdin.readline())
workers = {}
for i in range(n):
name, commute = sys.stdin.readline().split()
if commute == "enter":
workers[name] = 1
elif commute == "leave":
del workers[name]
for i in sorted(list(workers.items()), reverse=True):
print(i[0])
728x90
'dev > algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ / 10867๋ฒ / ์ค๋ณต ๋นผ๊ณ ์ ๋ ฌํ๊ธฐ [Go][Python3] (0) | 2020.12.09 |
---|---|
BOJ / 1934๋ฒ / ์ต์๊ณต๋ฐฐ์ [Go][Python3] (0) | 2020.12.08 |
BOJ / 2606๋ฒ / ๋ฐ์ด๋ฌ์ค [Go][Python3] (0) | 2020.12.06 |
BOJ / 1260๋ฒ / DFS์ BFS [Go][Python3] (0) | 2020.12.05 |
BOJ / 7596๋ฒ / MP3 Songs [Go][Python3] (0) | 2020.12.04 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
TAG
- ๋ถํ ์ ๋ณต
- ๋ฐฑ์ค
- Golang
- ๋ชฝ๊ณ ๋๋น
- MongoDB
- ๋งฅ๋ถ
- ๋ฐ๋
- go
- ์คํ
- AWS
- ๋งฅ๋ถํ๋ก
- BOJ
- ์๊ฐ๊ต์ฒด
- ballet
- dfs
- ํด์๋งต
- python3
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- ์ด๋ถํ์
- ์๊ณ ๋ฆฌ์ฆ
- java
- baekjoon
- ์๋ฐ
- ํ
- Macbook pro 2012 mid 13
- dp
- Algorithm
- ๋ธ๋ฃจํธํฌ์ค
- BFS
- ํ๋ก์ด๋์์ฌ
- Total
- Today
- Yesterday