#P6646. [CCO 2020] Shopping Plans

[CCO 2020] Shopping Plans

Description

There are NN items. Each item has a type aia_i and a price cic_i.

For type jj, you must buy a number of items within [xj,yj][x_j, y_j], meaning you must buy at least xjx_j items and at most yjy_j items of this type.

You need to output the costs of the cheapest KK plans. If no such plan exists, output -1.

In particular, if two plans have the same total cost but are different in the specific set of chosen items, they are considered two different plans.

Input Format

The first line contains three integers N,M,KN, M, K.

The next NN lines each contain two integers ai,cia_i, c_i.

The next MM lines each contain two integers xj,yjx_j, y_j.

Output Format

Output KK lines. Each line contains one integer. The ii-th line represents the cost of the ii-th cheapest plan.

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

Hint

Sample Explanation

There are 55 items and 22 types.

Type 11: {3,5,6}\{3,5,6\}, type 22: {1,3}\{1,3\}.

Both type 11 and type 22 can only choose one item.

For the cheapest plan, choose {1,3}\{1,3\}.

And so on.

Subtasks

This problem uses bundled testdata.

  • Subtask 1 (2020 points): xj,yj=1x_j, y_j = 1, N,M,K4×103N, M, K \le 4\times 10^3.
  • Subtask 2 (2020 points): xj,yj=1x_j, y_j = 1, N,M,ci4×103N, M, c_i \le 4\times 10^3.
  • Subtask 3 (2020 points): xj,yj=1x_j, y_j = 1.
  • Subtask 4 (2020 points): xj=0x_j = 0.
  • Subtask 5 (2020 points): No special restrictions.

For 100%100\% of the testdata, it is guaranteed that 1N,M,K2×1051\le N, M, K\le 2\times 10^5, 1aiM1\le a_i\le M, 1ci1091\le c_i\le 10^9, 0xjyjN0\le x_j\le y_j\le N.

Note

This problem is translated from Canadian Computing Olympiad 2020 Day 2 T3 Shopping Plans.

Translated by ChatGPT 5