Under construction

Still being built. Things may change

Costly Contest

Time limit1sMemory limit512 MB

Summary
Split n contestants into k contiguous age divisions and pick a problem subset for each so that the fewest contestants win prizes.
Level

Medium7 of 10

Topics
Dynamic programming, Sorting, Prefix sum
Solved
No attempts yet

Problem

The company Mindsight is holding a programming contest for nn contestants of varying ages. The contest will be separated into kk age divisions. The duration of the contest will be tt minutes, the same for all divisions. Mindsight has created a pool of mm available problems for use in the contest. Since all divisions compete at the same time, the same problems can be used in multiple divisions without any issues.

In each division, the participant who solves the largest number of problems gets a prize. In case of a tie (same number of problems solved), everyone tied for first place gets a prize. If no one in a division solves any problems, then everyone in that division gets a prize.

Mindsight has now come to the horrible realization that with these rules, all participants could win a prize. This could bankrupt the company! So the company has enlisted a team of experts to help resolve the situation.

The expert group analyzed the data in depth. For each of the nn participants, a slowness factor sis_i was determined. For each of the mm problems, a difficulty rating djd_j was assigned. The experts predict that the time it takes for participant ii to solve problem jj is si⋅djs_i \cdot d_j minutes. Participants cannot work on multiple problems in parallel, so the time it takes to solve multiple problems is the sum of the times for the individual problems. Participants always solve problems in increasing order of difficulty, starting with the easiest problem.

Now it is up to you, the underpaid intern, to configure the divisions so as to minimize the number of awarded prizes. Your task is to partition the nn participants into kk non-empty age divisions, and for each age division choose a non-empty subset of the mm available problems to use in that division. Each division must correspond to a contiguous age range of participants (for example, a division cannot cover ages 20 to 25 together with ages 30 to 35). The same problem may be used in multiple divisions.

Input

The first line of input contains four integers nn, mm, kk, tt (1≤n≤1051 \leq n \leq 10^5, 1≤m≤1001 \leq m \leq 100, 1≤k≤n1 \leq k \leq n, 1≤t≤1051 \leq t \leq 10^5): the number of participants nn, the number of available problems mm, the number of age divisions kk, and the duration of the contest tt. The second line contains nn integers s1,…,sns_1, \ldots, s_n (1≤si≤1051 \leq s_i \leq 10^5), the slowness factors of the participants. The participants are ordered by age, and no two participants have the same exact age. The third line contains mm integers d1,…,dmd_1, \ldots, d_m (1≤dj≤1051 \leq d_j \leq 10^5), the difficulty ratings of the problems.

Output

Output a single integer, the minimum number of prize winners.

Examples2

  1. Example 1

    Input
    4 3 2 10
    2 4 3 4
    11 3 6
    
    Expected output
    2
    
  2. Example 2

    Input
    4 3 1 10
    4 2 2 6
    2 4 4
    
    Expected output
    2