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

32603번 - Interrail Pass 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB32262683.871%

문제

Interrail passes are the fun and cheap way to see more of Europe, especially if you combine your train trip with Businesslike And Penny-saving Computation! In particular, you would like to find the cheapest way to pay for your planned travels. You plan to take the train on $n$ travel days, that are not necessarily consecutive. The individual fare is different for every day, and perhaps you can save money by buying some interrail passes.

There are $k$ different types of interrail passes with varying costs. Each type of interrail pass can be obtained multiple times. An interrail pass is active for a period of $p$ consecutive days, that starts on a day of your choice. The interrail pass covers the first $d$ travel days during this period, which do not have to be consecutive. Note that an active interrail pass cannot be "paused": a day of travel counts towards the day count of each active pass, even when you pay the individual fare that day.

As an example, consider the fourth sample input, visualized in Figure I.1. It is definitely cheaper to buy interrail passes than to pay 4ドル$ individual fares. The cheapest solution is to buy two interrail passes of the first type, rather than one interrail pass of the second type.

Figure I.1: Visualization of the types of interrail passes for the fourth sample input in a webshop. The first one can be activated for a period of 5ドル$ days, and can be used for 3ドル$ days within that period. The second one has a period of 30ドル$ days, and can be used for 5ドル$ days during that period.

입력

The input consists of:

  • One line with two integers $n$ and $k$ (1ドル\leq n\leq 10,000円,ドル 0ドル\leq k\leq 100$), the number of planned travel days, and the number of types of interrail passes available. \item $n$ lines, each with two integers $t$ and $f$ (0ドル\leq t \leq 10^6,ドル 1ドル\leq f\leq 10^5$), the travel day and the individual fare for that day. The $n$ travel days are distinct and given in increasing order.
  • $k$ lines, each with three integers $p,ドル $d,ドル and $c$ (1ドル\leq p\leq 10^6,ドル 1ドル\leq d\leq p,ドル 1ドル\leq c\leq 10^5$), indicating a type of interrail pass that is valid for a period of $p$ days, covers the first $d$ travel days in that period, and costs $c$.

출력

Output the minimum amount you need to spend to cover all your planned travels.

제한

예제 입력 1

2 1
0 10
1 10
2 2 15

예제 출력 1

15

예제 입력 2

2 1
0 10
2 10
2 2 15

예제 출력 2

20

예제 입력 3

3 1
0 10
1 10
2 10
5 2 15

예제 출력 3

25

예제 입력 4

4 2
3 80
5 90
24 70
26 60
5 3 100
30 5 212

예제 출력 4

200

예제 입력 5

4 1
42 9
43 2
44 9
45 9
4 3 20

예제 출력 5

29

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2024 I번

  • 문제를 만든 사람: Ragnar Groot Koerkamp
(追記) (追記ここまで)

출처

대학교 대회

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

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