luogu#P3918. [国家集训队] 特技飞行
[国家集训队] 特技飞行
Background
- wqs loves flight simulation.
- clj founded Shenben Airlines (pinyin). Since clj also wants to play games, you are in charge of managing the company.
Note: This is just a fictional background and does not correspond to real/simulated flying.
Problem Description
Shenben Airlines (pinyin) has launched a passenger-carrying stunt flying service. Each flight lasts time units. In each time unit, you can perform one stunt. There are types of stunts, and each type has an excitement level . If the same stunt is performed repeatedly, passengers get bored, so we define the value of performing a stunt as (time since the last time this same stunt was performed) . If it is the first time performing that stunt, the value is . Plan a schedule to maximize the total value.
Input Format
The first line contains two integers, and , as described above. The second line contains integers, the values for the stunt types.
Output Format
Output a single line with one integer, the maximum total value.
5 2
2 2
12
Hint
Constraints
- For 10% of the testdata, , .
- For 100% of the testdata, , , .
Translated by ChatGPT 5