#P15127. [ROIR 2026] 比赛结果
[ROIR 2026] 比赛结果
Problem Description
Students from the informatics group "Kapibara Programming" took part in a contest. According to the results, the student in position scored points.
To encourage the participants, the group leader Alexander Igorevich decided to give the students candies. For all and , if the student in position has a higher score than the student in position , then the leader will give the student in position candies.
Help the leader compute how many candies he needs to prepare to distribute to the students.
Input Format
The first line of the input gives an integer — the number of students ().
The second line contains integers — the contest scores of the group members ().
Output Format
Output one number — the total number of candies that need to be prepared for distribution to the students.
5
1 2 3 4 5
20
10
0 0 0 0 0 10000000 0 0 0 0
90000000
Hint
Note
Please note that the answer to this problem may exceed the possible value of a 32-bit integer variable, so you must use a 64-bit integer data type (int64 in Pascal, long long in C++, long in Java and C#).
Sample Explanation
In the first sample, the first student will not receive any candies, the second student will receive 1 candy, the third student will receive candies, the fourth student will receive candies, and the fifth student will receive candies.
Scoring Rules
The score for each subtask is awarded only if all testdata in that subtask and all its required subtasks are passed.
| Subtask | Points | Additional Constraints | Required Subtasks |
|---|---|---|---|
| 1 | 15 | ||
| 2 | 5 | All are the same | |
| 3 | For any , , and | ||
| 4 | 10 | ||
| 5 | 15 | 4 | |
| 6 | There are at most two distinct values among | 2, 4 | |
| 7 | 35 | None | 1–6 |
Translated by ChatGPT 5