OohMoo Milk

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

요약
매일 Farmer John은 A개의 병에 우유를 한 단위씩 채우고 Farmer Nhoj는 비어 있지 않은 B개의 병에서 한 단위씩 훔칠 때, 최종 우유량 제곱합의 게임값을 구한다.
난이도

어려움10점 중 8점

유형
그리디, 정렬, 게임 이론
정답자
아직 제출이 없습니다

문제

Farmer John is trying to make his world's famous OohMoo Milk to sell for a profit. He has NN (1≤N≤105)(1 \leq N \leq 10^5) bottles that he is trying to fill. Each bottle initially contains some amount of milk m_im\_i (0≤m_i≤109)(0 \leq m\_i \leq 10^9). Every day, he takes AA (1≤A≤N)(1 \le A \le N) bottles and fills each bottle with one unit of milk.

Unfortunately, Farmer Nhoj, Farmer John's competitor in the business of OohMoo Milk, knows about Farmer John's production processes and has a plan to curtail his business. Every day, after Farmer John fills his AA bottles, Farmer Nhoj will sneakily steal one unit of milk from each of BB (0≤B<A)(0 \le B < A) different nonempty bottles. To remain sneaky, Farmer Nhoj chooses BB so that it is strictly less than AA, so that it is less likely for Farmer John to discover him.

After DD (1≤D≤1091 \leq D \leq 10^9) days, Farmer John will sell his OohMoo Milk. If a bottle has MM units of milk, it will sell for M2M^2 moonies.

Let PP be the unique profit such that FJ can guarantee that he makes at least PP profit regardless of how FN behaves, and FN can guarantee that FJ makes at most PP profit regardless of how FJ behaves. Output the value of PP modulo 109+710^9+7.

입력

The first line of the input contains NN and DD, where NN is the number of bottles and DD is the number of days that take place.

The second line of the input contains AA and BB representing the number of units of milk that Farmer John fills and Farmer Nhoj steals respectively.

The third line of the input contains NN space-separated integers m_im\_i representing the initial amount of milk in each bottle.

출력

Output the value of PP modulo 109+710^9+7.

예제3

  1. 예제 1

    입력
    5 4
    4 2
    4 10 8 10 10
    
    예상 출력
    546
    
  2. 예제 2

    입력
    10 5
    5 1
    1 2 3 4 5 6 7 8 9 10
    
    예상 출력
    777
    
  3. 예제 3

    입력
    5 1000000000
    3 1
    0 1 2 3 4
    
    예상 출력
    10