ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ Go
// https://www.acmicpc.net/problem/1049
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
reader := bufio.NewReader(os.Stdin)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
var n, m int
fmt.Fscanln(reader, &n, &m)
var minPackage, minSingle = 1000, 1000
for i := 0; i < m; i++ {
var packagePrice, singlePrice int
fmt.Fscanln(reader, &packagePrice, &singlePrice)
if minPackage > packagePrice {
minPackage = packagePrice
}
if minSingle > singlePrice {
minSingle = singlePrice
}
}
var money int
if minSingle*6 > minPackage {
money += (n / 6) * minPackage
n %= 6
if n > 0 {
if minSingle*n > minPackage {
money += minPackage
} else {
money += minSingle * n
}
}
} else {
money += n * minSingle
}
fmt.Fprintln(writer, money)
}
๐จ Python3
# https://www.acmicpc.net/problem/1049
import sys
if __name__ == "__main__":
n, m = list(map(int, sys.stdin.readline().split()))
min_package, min_single = 1000, 1000
for i in range(m):
package_price, single_price = list(map(int, sys.stdin.readline().split()))
min_package = min(min_package, package_price)
min_single = min(min_single, single_price)
money = 0
if min_single*6 > min_package:
money += (n // 6) * min_package
n %= 6
if n > 0:
if min_single * n > min_package:
money += min_package
else:
money += min_single*n
else:
money += n * min_single
print(money)
728x90
'dev > algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ / 3048๋ฒ / ๊ฐ๋ฏธ [Go][Python3] (0) | 2021.02.21 |
---|---|
BOJ / 3085๋ฒ / ์ฌํ ๊ฒ์ [Go][Python3] (0) | 2021.02.20 |
BOJ / 15815๋ฒ / ์ฒ์ฌ ์ํ์ ์ฑํ [Go][Python3] (0) | 2021.02.18 |
BOJ / 1802๋ฒ / ์ข ์ด ์ ๊ธฐ [Go][Python3] (0) | 2021.02.17 |
BOJ / 2428๋ฒ / ํ์ [Go][Python3] (0) | 2021.02.16 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
TAG
- ์คํ
- Algorithm
- ๋ธ๋ฃจํธํฌ์ค
- python3
- ํด์๋งต
- BFS
- AWS
- ์ด๋ถํ์
- go
- ๋งฅ๋ถ
- ๋งฅ๋ถํ๋ก
- baekjoon
- ballet
- ํ
- MongoDB
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- dfs
- java
- ๋ชฝ๊ณ ๋๋น
- ์๊ฐ๊ต์ฒด
- ์๊ณ ๋ฆฌ์ฆ
- Golang
- Macbook pro 2012 mid 13
- ๋ฐ๋
- ์๋ฐ
- ๋ถํ ์ ๋ณต
- ๋ฐฑ์ค
- BOJ
- dp
- ํ๋ก์ด๋์์ฌ
- Total
- Today
- Yesterday