QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 256 MB مجموع النقاط: 100

#10506. Balance

الإحصائيات

Bajtazar received a scale for his thirteenth birthday. He was very happy with this gift and immediately started weighing all the objects around him. However, it quickly turned out that the scale is not very precise and always displays the mass rounded down to the nearest multiple of $c$ grams. The scale has one more drawback: if the mass of the load placed on it is at least $k \cdot c$ grams, the scale signals an error and does not provide any mass.

At first, Bajtazar was sad that he would not be able to accurately weigh all the objects he possesses. Nevertheless, the boy wants to learn as much as possible about them by taking advantage of the fact that he can place multiple objects on the scale at once. In this way, Bajtazar can obtain additional information about the weights of his objects. For example, this may be enough to determine with certainty for some pairs of objects that one of the considered objects is heavier than the other.

Your task is to determine for how many pairs of objects $(x, y)$ Bajtazar is able to conclude, using his scale, that $x$ weighs more than $y$. Fortunately, the masses of all objects in Bajtazar's possession are integer multiples of one gram. However, we assume that Bajtazar does not know any of these masses. Moreover, he does not even know that the masses of his objects are integers; he only assumes that each of these masses is expressed by some positive real number of grams. Bajtazar does, however, know the values of $k$ and $c$: he managed to find them in the scale's instruction manual.

Input

The first line of input contains three integers $n$, $k$, and $c$ ($1 \le n, k \le 1\,000$, $1 \le c \le 5\,000$), representing the number of objects in Bajtazar's possession and the scale parameters, respectively. The scale weighs with an accuracy of $c$ grams and displays the mass rounded down if the load placed on it weighs less than $k \cdot c$ grams; the scale signals an error if the load placed on it weighs at least $k \cdot c$ grams.

The second line of input contains $n$ integers $a_1, \dots, a_n$ ($1 \le a_i < k \cdot c$), representing the weights of the consecutive objects in grams.

Output

Output the number of pairs $(x, y)$ of objects in Bajtazar's possession such that, after a certain number of weighings, it can be concluded that $x$ is heavier than $y$.

Examples

Input 1

4 4 6
8 9 10 11

Output 1

4

Note 1

Bajtazar is able to conclude that the objects in pairs $(1, 3)$, $(1, 4)$, $(2, 3)$, and $(2, 4)$ have different masses.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.