#P6418. [COCI 2014/2015 #1] ZABAVA
[COCI 2014/2015 #1] ZABAVA
Description
A new apartment complex has opened, and it has buildings.
Now there are students. Each day, exactly one student moves in.
After a student enters a building, a party will be held in that building, and the noise index of the party equals the current number of students in that building.
However, you may perform up to operations. In each operation, you can kick all students in one building out of this new apartment complex.
Note that the student enters the building first, and only then can you perform an operation.
Now find the minimum possible total sum of the noise indices.
You do not have to use all operations.
Input Format
The first line contains three integers .
The next lines each contain one integer . Line means that on day , the -th student moves into building .
Output Format
Output one line: the minimum possible total sum of the noise indices.
5 1 2
1
1
1
1
1
7
11 2 3
1
2
1
2
1
2
1
2
1
2
1
18
Hint
Sample Explanation
Explanation for Sample Input/Output 1
You can clear building on day and day . Then the noise index for each day is . If you never clear, the noise index for each day is .
Explanation for Sample Input/Output 2
Clear building on day and day , and clear building on day . Then the noise index for each day is .
Constraints
- For points, it is guaranteed that .
- For points, it is guaranteed that .
- For points, it is guaranteed that .
- For of the testdata, it is guaranteed that , , , .
Notes
The total score for this problem is points.
This problem is translated from Croatian Open Competition in Informatics 2014/2015 Contest #1 T5 ZABAVA.
Translated by ChatGPT 5
京公网安备 11011102002149号