아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Cocktails

시간 제한2초메모리 제한256 MB

요약
각 병의 수동 블렌딩 시간과 연속한 k개 병을 B초에 처리하는 블렌더, 두 병을 C초에 맞바꾸는 교환이 주어질 때 모든 병을 블렌딩하는 최소 시간을 구한다.
난이도

보통10점 중 7점

유형
동적 계획법, 정렬, 그리디
정답자
아직 제출이 없습니다

문제

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 nn different ingredients. There are nn 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 ii-th jar by hand takes a_ia\_i seconds. Also, you have a very powerful blender which can blend the contents in any kk subsequent jars in BB seconds (the blender can be applied any number of times). Finally, you can swap any two jars in CC 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 nn 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 nn, kk, BB, CC (1≤k≤n≤5001 \leq k \leq n \leq 500, 1≤B,C≤10,0001 \leq B, C \leq 10\\,000) --- 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 nn space-separated integers a_1a\_1, …\ldots, a_na\_n (1≤a_i≤10,0001 \leq a\_i \leq 10\\,000), where a_ia\_i is the time needed to manually blend the contents of ii-th jar.

출력

Print a single integer --- the smallest time needed to blend the contents in all jars.

예제1

  1. 예제 1

    입력
    5 2 10 3
    10 1 20 2 3
    
    예상 출력
    19