Logo
(追記) (追記ここまで)

19616번 - Shopping Plans 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB117222019.417%

문제

You are shopping from a store that sells a total of N items. The i-th item has a type ai which is an integer between 1 and M. A feasible shopping plan is a subset of these items such that for all types j, the number of items of type j is in the interval [xj, yj].

The i-th item in the store has a cost of ci, and the cost of a shopping plan is the sum of the costs of items in the plan. You are interested in the possible costs of feasible shopping plans. Find the costs of the K cheapest feasible shopping plans. Note that if there are two different shopping plans with the same cost, they should be counted separately in the output.

입력

The first line consists of three space-separated integers N, M, and K (1 ≤ N, M, K ≤ 200 000). N lines follow, the i-th of which contains two space-separated integers ai and ci (1 ≤ ai ≤ M, 1 ≤ ci ≤ 109). M lines follow, the j-th of which contains two space-separated integers xj and yj (0 ≤ xj ≤ yj ≤ N).

출력

Output K lines. On the i-th line, output the cost of the i-th cheapest feasible shopping plan, if one exists, or -1 if there are fewer than i feasible shopping plans.

제한

예제 입력 1

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

예제 출력 1

4
6
6
7
8
9
-1

힌트

A feasible shopping plan must combine exactly one item with a cost in {5, 3, 6} with exactly one item with a cost in {3, 1}.

출처

Olympiad > Canadian Computing Competition & Olympiad > 2020 > CCO 2020 6번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /