QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 32 MB Total points: 10

#11834. Conference - Rectification [A]

統計

You must have heard about Great Bitonic Conference (if not, read the description of the "Conference" task). Organizers of the GBC are in trouble again and they are seeking your help. The original version of the registration system has a special mechanism for maximizing the income from the conference. It is achieved by canceling some of the booked tickets (it allows to reduce expenses on the renting of conference rooms). Such an approach is not acceptable however. People are dissatisfied with the fact that conference's organizers cancelled some of the tickets booked within a single reservation. You are asked to modify the registration system in such way, that the income from the conference is maximized, while cancellation of only whole reservations is allowed.

Write a program which:

  • reads from the standard input the prices of tickets, the size of a room, the cost of renting a room and the list of reservations,
  • calculates maximal profit from the conference, that can be obtained by potentially cancelling some of the reservations,
  • writes the result to the standard output.

Input Format

In the first line of the standard input there are four integers: $ m $, $ l $, $ k $ and $ s $ (1 ≤ $ m $ ≤ 100, 2 ≤ $ l $ ≤ 1 000 000, 2 ≤ $ k $ ≤ 400, 1 ≤ $ s $ ≤ 1 000), separated by single spaces. They represent: the number of presentations, the number of reservations, the size of a single room and the cost of renting a single room. The second line contains exactly $ m $ numbers $ c_{i} $ ($ c_{i} $ · ⌊$ k $ / 2⌋ ≥ $ s $, $ c_{i} $ ≤ $ s $), separated by single spaces (the lower limit on the value of $ c_{i} $ is due to profitability of renting a room for ⌊$ k $ / 2⌋ participants of a conference). They represent prices of tickets for the presentations (numbered from 1 to $ m $). Following $ l $ lines contain descriptions of reservations. Each reservation is represented by two integers $ p_{i} $ and $ r_{i} $ (1 ≤ $ p_{i} $ ≤ $ m $, 1 ≤ $ r_{i} $ ≤ 1 000), separated by a single space. They represent the number of a presentation and the number of tickets booked for this presentation. It is only allowed to cancel all tickets reserved within the same reservation.

Output Format

The first and only line of the standard output should contain exactly one integer - the total income that can be obtained by potentially cancelling only whole reservations.

Example

Input

3 2 10 30
7 10 8
1 9
3 13

Output

77
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.