| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 32 | 26 | 26 | 83.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:
Output the minimum amount you need to spend to cover all your planned travels.
2 1 0 10 1 10 2 2 15
15
2 1 0 10 2 10 2 2 15
20
3 1 0 10 1 10 2 10 5 2 15
25
4 2 3 80 5 90 24 70 26 60 5 3 100 30 5 212
200
4 1 42 9 43 2 44 9 45 9 4 3 20
29
ICPC > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2024 I번