CF1154F.Shovels Shop

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There are nn shovels in the nearby shop. The ii -th shovel costs aia_i bourles.

Misha has to buy exactly kk shovels. Each shovel can be bought no more than once.

Misha can buy shovels by several purchases. During one purchase he can choose any subset of remaining (non-bought) shovels and buy this subset.

There are also mm special offers in the shop. The jj -th of them is given as a pair (xj,yj)(x_j, y_j) , and it means that if Misha buys exactly xjx_j shovels during one purchase then yjy_j most cheapest of them are for free (i.e. he will not pay for yjy_j most cheapest shovels during the current purchase).

Misha can use any offer any (possibly, zero) number of times, but he cannot use more than one offer during one purchase (but he can buy shovels without using any offers).

Your task is to calculate the minimum cost of buying kk shovels, if Misha buys them optimally.

输入格式

The first line of the input contains three integers n,mn, m and kk ( 1n,m2105,1kmin(n,2000)1 \le n, m \le 2 \cdot 10^5, 1 \le k \le min(n, 2000) ) — the number of shovels in the shop, the number of special offers and the number of shovels Misha has to buy, correspondingly.

The second line of the input contains nn integers a1,a2,,ana_1, a_2, \dots, a_n ( 1ai21051 \le a_i \le 2 \cdot 10^5 ), where aia_i is the cost of the ii -th shovel.

The next mm lines contain special offers. The jj -th of them is given as a pair of integers (xi,yi)(x_i, y_i) ( 1yixin1 \le y_i \le x_i \le n ) and means that if Misha buys exactly xix_i shovels during some purchase, then he can take yiy_i most cheapest of them for free.

输出格式

Print one integer — the minimum cost of buying kk shovels if Misha buys them optimally.

输入输出样例

  • 输入#1

    7 4 5
    2 5 4 2 6 3 1
    2 1
    6 5
    2 1
    3 1
    

    输出#1

    7
    
  • 输入#2

    9 4 8
    6 8 5 1 8 1 1 2 1
    9 2
    8 4
    5 3
    9 7
    

    输出#2

    17
    
  • 输入#3

    5 1 4
    2 5 7 4 6
    5 4
    

    输出#3

    17
    

说明/提示

In the first example Misha can buy shovels on positions 11 and 44 (both with costs 22 ) during the first purchase and get one of them for free using the first or the third special offer. And then he can buy shovels on positions 33 and 66 (with costs 44 and 33 ) during the second purchase and get the second one for free using the first or the third special offer. Then he can buy the shovel on a position 77 with cost 11 . So the total cost is 4+2+1=74 + 2 + 1 = 7 .

In the second example Misha can buy shovels on positions 11 , 22 , 33 , 44 and 88 (costs are 66 , 88 , 55 , 11 and 22 ) and get three cheapest (with costs 55 , 11 and 22 ) for free. And then he can buy shovels on positions 66 , 77 and 99 (all with costs 11 ) without using any special offers. So the total cost is 6+8+1+1+1=176 + 8 + 1 + 1 + 1 = 17 .

In the third example Misha can buy four cheapest shovels without using any special offers and get the total cost 1717 .

首页