문제 링크
https://www.acmicpc.net/problem/1421
from math import ceil
n, c, w = map(int, input().split())
trees = [int(input()) for _ in range(n)]
profit=[]
for i in range(1,max(trees)+1):
L = sum([(tree // i) for tree in trees])
cost = sum([(ceil(tree/i)-1)*c for tree in trees])
profit.append(L * i * w - cost)
print(max(profit))
from math import ceil
n, c, w = map(int, input().split())
trees = [int(input()) for _ in range(n)]
profits=[]
for L in range(1,max(trees)+1):
profit = []
for tree in trees:
profit.append(max(0,(tree // L)*L*w - (ceil(tree / L)-1)*c))
profits.append(sum(profit))
print(max(profits))