ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ Go
// https://www.acmicpc.net/problem/20291
package main
import (
"bufio"
"fmt"
"os"
"sort"
"strings"
)
func main() {
reader := bufio.NewReader(os.Stdin)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
var n int
fmt.Fscanln(reader, &n)
extMap := map[string]int{}
for i := 0; i < n; i++ {
var filepath string
fmt.Fscanln(reader, &filepath)
ext := strings.Split(filepath, ".")[1]
extMap[ext]++
}
sortedKeys := []string{}
for key := range extMap {
sortedKeys = append(sortedKeys, key)
}
sort.Strings(sortedKeys)
for _, key := range sortedKeys {
fmt.Fprintf(writer, "%s %d\n", key, extMap[key])
}
}
๐จ Python3
# https://www.acmicpc.net/problem/20291
import sys
if __name__ == "__main__":
n = int(sys.stdin.readline())
ext_dict = {}
for i in range(n):
_, ext = sys.stdin.readline().rstrip().split(".")
if ext_dict.get(ext):
ext_dict[ext] += 1
else:
ext_dict[ext] = 1
for key in sorted(ext_dict.keys()):
print('{} {}'.format(key, ext_dict[key]))
728x90
'dev > algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ / 7596๋ฒ / MP3 Songs [Go][Python3] (0) | 2020.12.04 |
---|---|
BOJ / 2204๋ฒ / ๋๋น์ ๋๋ ์ฆ ํ ์คํธ [Go][Python3] (0) | 2020.12.03 |
BOJ / 14235๋ฒ / ํฌ๋ฆฌ์ค๋ง์ค ์ ๋ฌผ [Python3] (0) | 2020.12.01 |
BOJ / 11286๋ฒ / ์ ๋๊ฐ ํ [Go][Python3] (0) | 2020.11.30 |
BOJ / 1927๋ฒ / ์ต์ ํ [Go][Python3] (0) | 2020.11.29 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
TAG
- ์๋ฐ
- AWS
- ๋ชฝ๊ณ ๋๋น
- ๋งฅ๋ถํ๋ก
- BFS
- dfs
- ballet
- ์ด๋ถํ์
- ์๊ณ ๋ฆฌ์ฆ
- ๋ธ๋ฃจํธํฌ์ค
- BOJ
- ํด์๋งต
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- baekjoon
- java
- ์คํ
- ํ๋ก์ด๋์์ฌ
- ์๊ฐ๊ต์ฒด
- python3
- ๋ถํ ์ ๋ณต
- Algorithm
- ๋ฐ๋
- ๋งฅ๋ถ
- Macbook pro 2012 mid 13
- ํ
- go
- Golang
- ๋ฐฑ์ค
- MongoDB
- dp
- Total
- Today
- Yesterday