Hide

Problem I
Hatter's Hat Shop

/problems/hattershatshop/file/statement/en/img-0001.png
Sophie at her hat shop

Sophie works at a hat shop. She is trying to decorate N hats, where each hat belongs to one of M different designs (denoted by an integer from 1 to M). Each hat also starts with a different amount of starting beauty Sj.

Hats of the same design share some properties. All hats belonging to the same design i have the same maximum beauty Ci. Moreover, Sophie has enough time to devise K new decorations. When designing a decoration, Sophie must pick a design i (so that her decorations have standard measurements). After finishing her design, she then applies this decoration to each hat of design i, resulting in each hat belonging to that design having its beauty increased by an amount Fi. However, a hat of design i will never be able to be more beautiful than Ci. In the case you try to improve a hat already at peak beauty, the hat simply remains at that peak. Moreover, Sophie can choose to make multiple decorations for the same hat design. Sophie wants to maximize the total beauty of her hats. Thus, after creating K new decorations, what is the maximum possible sum of the beauty of all N hats?

Input

The first line of input contains three space separated integers N(1N200000), M(1M200000), and K(1K109), denoting the number of hats, the number of hat designs, and the number of decorations Sophie can devise, respectively.
Each of the next M lines contains two space separated integers Fi and Ci such that 1Ci109 and 1FiCi, where Fi represents how much hats of design i are improved by one decoration and Ci represents the max beauty of this hat design.
Each of the next N lines contains two space separated integers Tj(1TjM) and Sj(0SjCTj), where Tj represents the design of hat j and Sj represents the amount of starting beauty of hat j.

Output

Output one line containing a single number, representing the maximum possible sum of the beauty of all N hats after Sophie creates K new decorations.

Sample Input 1 Sample Output 1
4 2 2
1 3
2 5
1 1
1 2
2 4
2 3
15
Hide

Please log in to submit a solution to this problem

Log in