Cocktails
시간 제한2초메모리 제한256 MB
각 병의 수동 블렌딩 시간과 연속한 k개 병을 B초에 처리하는 블렌더, 두 병을 C초에 맞바꾸는 교환이 주어질 때 모든 병을 블렌딩하는 최소 시간을 구한다.
문제
A party is coming tonight, and drinks are not ready yet! You are going to prepare a cocktail for your friends. The cocktail consists of different ingredients. There are jars in front of you, numbered from left to right starting from 1. Each of the jars contains a single ingredient. You have to blend each ingredient in its separate jar.
Blending the contents of -th jar by hand takes seconds. Also, you have a very powerful blender which can blend the contents in any subsequent jars in seconds (the blender can be applied any number of times). Finally, you can swap any two jars in seconds (the two jars don't have to be adjacent). It is allowed to blend the contents of any jar more than once.
What is the smallest possible time to blend the ingredients in all jars? The final order of jars does not matter as long as they are all blended.
입력
In the first line of input there are four space-separated integers , , , (, ) --- the number of jars, the reach of the blender, the time needed to use the blender, and the time needed to swap two jars respectively.
In the second line there are space-separated integers , , (), where is the time needed to manually blend the contents of -th jar.
출력
Print a single integer --- the smallest time needed to blend the contents in all jars.