#P9506. [BalkanOI 2018] Homecoming
[BalkanOI 2018] Homecoming
Background
Translated from BalkanOI 2018 Day 1 T2 “Homecoming”. Since Luogu is much slower than loj, the time limit is adjusted from 300 ms to 500 ms.
Problem Description
There are courses, numbered from to . If you pass course , you can earn dollars.
There are textbooks, numbered from to . The price of textbook is dollars.
If you want to pass course , you need to buy the textbooks numbered $i, (i+1) \bmod N, (i+2) \bmod N, \cdots, (i+K-1) \bmod N$. is a given constant.
Your goal is to make money rather than pass all courses. Please compute the maximum number of dollars you can earn.
Input Format
See “Interaction”.
Output Format
See “Interaction”.
Hint
Constraints and Limits
Let the sum of over all calls to the solve function be , and the sum of be . Then:
The detailed subtasks and additional limits are shown in the table below.
| Subtask ID | Additional Limits | Score |
|---|---|---|
| No additional limits |
Translated by ChatGPT 5