ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ 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
- MongoDB
- python3
- Macbook pro 2012 mid 13
- ๋ถํ ์ ๋ณต
- ํด์๋งต
- ์ด๋ถํ์
- AWS
- ํ๋ก์ด๋์์ฌ
- ์คํ
- dp
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- Golang
- java
- ์๊ฐ๊ต์ฒด
- go
- Algorithm
- ๋งฅ๋ถํ๋ก
- ๋ฐ๋
- BFS
- ๋งฅ๋ถ
- ๋ฐฑ์ค
- ๋ชฝ๊ณ ๋๋น
- ์๋ฐ
- ํ
- dfs
- ๋ธ๋ฃจํธํฌ์ค
- ballet
- BOJ
- ์๊ณ ๋ฆฌ์ฆ
- baekjoon
- Total
- Today
- Yesterday