{"problem":{"name":"Histogram","description":{"content":"Given are integer sequences of length $N$ each: $A = (A_1, \\dots, A_N)$ and $C = (C_1, \\dots, C_N)$. You can do the following operation any number of times, possibly zero. *   Choose an integer $i$ s","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc228_h"},"statements":[{"statement_type":"Markdown","content":"Given are integer sequences of length $N$ each: $A = (A_1, \\dots, A_N)$ and $C = (C_1, \\dots, C_N)$.\nYou can do the following operation any number of times, possibly zero.\n\n*   Choose an integer $i$ such that $1 \\leq i \\leq N$ and add $1$ to the value of $A_i$, for a cost of $C_i$ yen (Japanese currency).\n\nAfter you are done with the operation, you have to pay $K \\times X$ yen, where $K$ is the number of different values among the elements of $A$.\nWhat is the minimum total amount of money you have to pay?\n\n## Constraints\n\n*   $1 \\leq N \\leq 2 \\times 10^5$\n*   $1 \\leq X \\leq 10^6$\n*   $1 \\leq A_i, C_i \\leq 10^6 \\, (1 \\leq i \\leq N)$\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ $X$\n$A_1$ $C_1$\n$\\vdots$\n$A_N$ $C_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc228_h","tags":[],"sample_group":[["3 5\n3 2\n2 4\n4 3","12\n\nAfter adding $1$ to $A_1$, there will be two different values among the elements of $A$, for a total cost of $C_1 + 2 \\times X = 12$ yen. It is impossible to make the total cost less than this."],["1 1\n1 1","1"],["7 7\n3 2\n1 7\n4 1\n1 8\n5 2\n9 8\n2 1","29"]],"created_at":"2026-03-03 11:01:14"}}