mirror of https://github.com/01-edu/public.git
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
849 B
56 lines
849 B
5 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"os"
|
||
|
"strconv"
|
||
|
)
|
||
|
|
||
|
func min(numbers ...int) int {
|
||
5 years ago
|
min := numbers[0]
|
||
|
for _, i := range numbers {
|
||
|
if i < min {
|
||
|
min = i
|
||
5 years ago
|
}
|
||
|
}
|
||
5 years ago
|
return min
|
||
5 years ago
|
}
|
||
|
|
||
|
func max(numbers ...int) int {
|
||
5 years ago
|
max := numbers[0]
|
||
|
for _, i := range numbers {
|
||
|
if i > max {
|
||
|
max = i
|
||
5 years ago
|
}
|
||
|
}
|
||
5 years ago
|
return max
|
||
5 years ago
|
}
|
||
|
|
||
5 years ago
|
func costumeProfit(a, b, c, d, e, f int) int {
|
||
5 years ago
|
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])
|
||
|
|
||
5 years ago
|
fmt.Println(costumeProfit(a, b, c, d, e, f))
|
||
5 years ago
|
}
|