func main() var n: int :: cui@inputInt() var a: int :: cui@inputInt() var b: int :: cui@inputInt() var c: int :: cui@inputInt() var x: int :: n / 30 * 30 var ans: int :: 0 do ans :+ [x / 3 * a, x / 5 * b, x / 10 * c].max() do n :- x var max: int :: 0 for an(0, 10) for bn(0, 6) for cn(0, 3) if(an * 3 + bn * 5 + cn * 10 <= n) var v: int :: an * a + bn * b + cn * c if(v > max) do max :: v end if end if end for end for end for do ans :+ max do cui@print("\{ans}\n") end func