ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ Go
// https://www.acmicpc.net/problem/20207
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)
scheduleMap := map[int]int{}
for i := 0; i < n; i++ {
var s, e int
fmt.Fscanln(reader, &s, &e)
for j := s; j <= e; j++ {
scheduleMap[j]++
}
}
keys := []int{}
for key := range scheduleMap {
keys = append(keys, key)
}
sort.Ints(keys)
var maxWidth, maxHeight, area int
for i, val := range keys {
if i != 0 && keys[i-1]+1 != val {
area += maxWidth * maxHeight
maxWidth = 0
maxHeight = 0
}
maxWidth++
if scheduleMap[val] > maxHeight {
maxHeight = scheduleMap[val]
}
}
area += maxWidth * maxHeight
fmt.Fprintln(writer, area)
}
728x90
'dev > algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ / 10815๋ฒ / ์ซ์ ์นด๋ [Go][Python3] (0) | 2020.11.26 |
---|---|
BOJ / 2110๋ฒ / ๊ณต์ ๊ธฐ ์ค์น [Go][Python3] (0) | 2020.11.25 |
BOJ / 20206๋ฒ / ํธ์์ด๊ฐ ๊ธธ์ ๊ฑด๋๊ฐ ์ด์ [Go] (0) | 2020.11.23 |
BOJ / 20205๋ฒ / ๊ต์๋ ๊ทธ๋ฆผ์ด ๊นจ์ง๋๋ฐ์? [Go] (0) | 2020.11.22 |
BOJ / 2805๋ฒ / ๋๋ฌด ์๋ฅด๊ธฐ [Go][Python3] (0) | 2020.11.21 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
TAG
- ํด์๋งต
- ์๊ฐ๊ต์ฒด
- ์คํ
- ๋ธ๋ฃจํธํฌ์ค
- ์๋ฐ
- dp
- ํ
- Macbook pro 2012 mid 13
- java
- BFS
- Golang
- ballet
- MongoDB
- ์ด๋ถํ์
- Algorithm
- ์๊ณ ๋ฆฌ์ฆ
- ๋ชฝ๊ณ ๋๋น
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- ํ๋ก์ด๋์์ฌ
- ๋ฐ๋
- ๋งฅ๋ถ
- baekjoon
- ๋งฅ๋ถํ๋ก
- dfs
- BOJ
- ๋ฐฑ์ค
- AWS
- python3
- ๋ถํ ์ ๋ณต
- go
- Total
- Today
- Yesterday