포럼
문제 ICPC00362

I. Interrail Pass

설명

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 . 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.

제약
입력 형식

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.
- \(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
출력
15
예제 2
입력
2 1
0 10
2 10
2 2 15
출력
20
예제 3
입력
3 1
0 10
1 10
2 10
5 2 15
출력
25
예제 4
입력
4 2
3 80
5 90
24 70
26 60
5 3 100
30 5 212
출력
200
예제 5
입력
4 1
42 9
43 2
44 9
45 9
4 3 20
출력
29
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC BAPC 2024

평가 및 의견

I. Interrail Pass

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

I. Interrail Pass

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8