#P7823. 「RdOI R3」闹钟
「RdOI R3」闹钟
Description
You have an alarm clock. The timer settings of the alarm clock can be represented by two variables , both starting with an initial value of . Adjusting a variable from to costs .
Next, you are given numbers . On day , you need to adjust the variables so that at least one of the two variables equals . Find the minimum total cost.
Input Format
The first line contains an integer .
The second line contains integers .
Output Format
Output one integer in one line, representing the minimum cost.
6
1 1 4 5 1 4
7
5
4 1 9 2 3
12
Hint
Sample Explanation
Sample explanation 1:
Day 1: .
Day 2: .
Day 3: .
Day 4: .
Day 5: .
Day 6: .
Sample explanation 2:
Day 1: .
Day 2: .
Day 3: .
Day 4: .
Day 5: .
Constraints
| Test ID | Special property | |
|---|---|---|
| None | ||
| None | ||
| None |
In addition, to catch some incorrect solutions, this problem includes several hack test points. The testdata of the hack test points satisfy and . If your program does not pass at least one hack test point, then the score for this problem will be .
For of the testdata, and .
Translated by ChatGPT 5
京公网安备 11011102002149号