You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
851 B

package main
import (
"fmt"
"os"
"strconv"
)
func min(numbers ...int) int {
min := numbers[0]
for _, i := range numbers {
if i < min {
min = i
}
}
return min
}
func max(numbers ...int) int {
max := numbers[0]
for _, i := range numbers {
if i > max {
max = i
}
}
return max
}
func Costume_profit(a, b, c, d, e, f int) int {
if d == min(a, b, c, d) {
return d * max(e, f)
}
if e > f {
ans := min(a, d) * e
d -= min(a, d)
ans += min(d, b, c) * f
return ans
}
ans := min(b, c, d) * f
d -= min(b, c, d)
ans += min(a, d) * e
return ans
}
func main() {
args := os.Args[1:]
a, _ := strconv.Atoi(args[0])
b, _ := strconv.Atoi(args[1])
c, _ := strconv.Atoi(args[2])
d, _ := strconv.Atoi(args[3])
e, _ := strconv.Atoi(args[4])
f, _ := strconv.Atoi(args[5])
fmt.Println(Costume_profit(a, b, c, d, e, f))
}