{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eAlice and Bob are playing cards. Each of them has been given $$$n$$$ cards with a number on each card. They will play the cards for $$$n$$$ rounds, and in each round, each player will play a card that hasn\u0027t been played before. After both Alice and Bob play a card in a round, they will compare the number written on the cards, and the person who plays a card with a larger number will win this round. In the case that the numbers written on two cards are exactly the same, this round will be a draw.\u003c/p\u003e\u003cp\u003eAlice has a very strong competitive heart. She doesn\u0027t want to lose in any round. If in any round she discovered that the number on the card played by her is smaller than the one played by Bob, she will cheat several times. Cheating once, she can increase the number written on her card by $$$k$$$, and she will keep cheating in a round until the number on her card \u003cspan class\u003d\"tex-font-style-bf\"\u003eis not smaller\u003c/span\u003e than the number on Bob\u0027s card. \u003c/p\u003e\u003cp\u003eHowever, cheating is very risky, therefore she wants to minimize the times of cheating. To achieve that, she managed to know the sequence of cards that will be played by Bob, and she can determine the order to play the cards in her hands. Please help her calculate the minimum cheating times.\u003c/p\u003e\u003cp\u003eFormally, we can denote the cards in Alice\u0027s hands by $$$a_1,a_2,\\ldots,a_n$$$, and denote the sequence of cards that will be played by Bob by $$$b_1,b_2,\\ldots,b_n$$$. You should find a permutation of $$$n$$$ denoted by $$$c_1,c_2,\\ldots,c_n$$$, such that \u003c/p\u003e\u003cp\u003e$$$$$$ \\sum\\limits_{i\u003d1}^n\\left\\lceil \\frac{\\max(b_i-a_{c_i},0)}k\\right\\rceil $$$$$$ \u003c/p\u003e\u003cp\u003eis minimized. You should output the minimized value and a possible sequence $$$c_1,c_2,\\ldots,c_n$$$.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains two integers $$$n$$$ ($$$1\\leq n\\leq 10^5$$$) and $$$k$$$ ($$$1\\leq k \\leq 10^9$$$), indicating the number of cards on each player\u0027s hands and the number that can be increased per cheating action.\u003c/p\u003e\u003cp\u003eThe second line contains $$$n$$$ integers $$$a_1,a_2,...,a_n$$$ ($$$1\\leq a_i\\leq 10^9$$$), denoting the cards on Alice\u0027s hands.\u003c/p\u003e\u003cp\u003eThe third line contains $$$n$$$ integers $$$b_1,b_2,...,b_n$$$ ($$$1\\leq b_i\\leq 10^9$$$), denoting the sequence of cards played by Bob. Note that Bob will play the cards in the order of the sequence.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eYou should output two lines.\u003c/p\u003e\u003cp\u003eIn the first line, output a single integer indicating the minimum times to cheat.\u003c/p\u003e\u003cp\u003eIn the second line, output $$$n$$$ integers $$$c_1,c_2,...,c_n$$$, indicating the order of cards played by Alice to minimize the cheating times. That is, Alice will play a card with the number $$$a_{c_i}$$$ in round $$$i$$$. If there are multiple answers, print any.\u003c/p\u003e"}},{"title":"Examples","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e4 2\n2 7 6 4\n3 9 1 8\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\n4 2 1 3\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}