Under construction

Still being built. Things may change

Express Train

Interview

Time limit1sMemory limit1024 MB

Summary
Pick exactly M stations for passing tracks to minimize the total running time of X regular trains and Y express trains.
Level

Medium4 of 10

Topics
Greedy, Sorting
Solved
No attempts yet

Problem

The city plans to convert one subway line in Seoul into an express line. Unlike regular (local) trains, which stop at every station, express trains stop only at some stations. Passing tracks are built so that express trains can overtake regular trains.

The line will run two kinds of trains, regular and express. The line has NN stations, numbered 1 to NN, and both regular and express trains take KK minutes to run the whole line. If a passing track is built at station ii (1≤i≤N1 \le i \le N), the running time of regular trains increases by AiA_i minutes, and the running time of express trains decreases by BiB_i minutes. Each station can have at most one passing track.

The line runs XX regular trains and YY express trains. The total running time of all trains is defined as (running time of a regular train) ×X\times X + (running time of an express train) ×Y\times Y. Choose exactly MM of the NN stations and build passing tracks there. Find the minimum possible total running time of all trains after the passing tracks are built.

Input

The first line contains NN, MM, KK, XX, and YY, separated by spaces.

The ii-th of the next NN lines contains AiA_i and BiB_i, separated by a space.

Output

On the first line, print the minimum possible total running time of all trains after the passing tracks are built.

Constraints

All input values are integers.

  • 1≤M≤N≤100 0001 \le M \le N \le 100\,000
  • 1≤K,X,Y≤1091 \le K, X, Y \le 10^9
  • 0≤Ai,Bi≤1 0000 \le A_i, B_i \le 1\,000
  • ∑i=1NBi<K\sum_{i=1}^{N} B_i < K. In other words, only inputs where the express running time stays positive after the passing tracks are built are given.

Examples1

  1. Example 1

    Input
    3 2 20 1 1
    5 3
    3 4
    2 5
    
    Expected output
    36