{"trustable":true,"sections":[{"title":"","value":{"format":"MD","content":"### Read problems statements in [Mandarin Chinese](https://www.codechef.com/download/translated/COOK128/mandarin/BUILDB.pdf), [Russian](https://www.codechef.com/download/translated/COOK128/russian/BUILDB.pdf), and [Bengali](https://www.codechef.com/download/translated/COOK128/bengali/BUILDB.pdf) as well.\r\n\r\nAfter solving programming problems for years, Chef has become lazy and decided to get a better physique by doing some weight lifting exercises.\r\n\r\nOn any regular day, Chef does $N$ exercises at times $A_1, A_2, \\ldots, A_N$ (in minutes, all distinct) and each exercise provides a tension of $B_1, B_2, \\ldots, B_N$ units. In the period between two consecutive exercises, his muscles relax $R$ units of tension per minute.\r\n\r\nMore formally, Chef\u0027s tension is described by a number $x$. Before any workouts, $x\u003d0$. When he does a workout at time $A_i$, the tension $x$ instantly increases by $B_i$. Between workouts, the number $x$ decreases by $R$ units per minute, maximized with $0$.\r\n\r\nConsidering the time of exercise and hence tension to be negligible, find the maximum tension he will be feeling in his muscles during the entire period of his workout.\r\n\r\n### Input:\r\n\r\n- First line will contain $T$, number of testcases. Then the testcases follow. \r\n- Each testcase contains $3$ lines of input.\r\n- The first line will contain $2$ space-separated integers $N, R$, number of timestamps at which Chef performs his exercise, and units of tension relaxed per minute.\r\n- The second line contains $N$ space-separated integers $A_1, A_2, \\ldots, A_N$.\r\n- The third line contains $N$ space-separated integers $B_1, B_2, \\ldots, B_N$. \r\n\r\n### Output:\r\nFor each testcase, output in a single line the maximum amount of tension Chef will have in his muscles.\r\n\r\n### Constraints \r\n- $1 \\leq T \\leq 10$\r\n- $1 \\leq N \\leq 5\\cdot 10^4$\r\n- $1 \\leq R, B_i \\leq 10^5$\r\n- $1 \\leq A_i \\leq 10^9$\r\n- $A_{i - 1} \\lt A_i$, for all $2\\le i\\le N$"}},{"title":"Sample 1","value":{"format":"MD","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\u003e3\r\n1 2\r\n10\r\n10\r\n2 2\r\n10 11\r\n10 10\r\n3 1\r\n1 2 3\r\n1 2 3\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e10\r\n18\r\n4\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n**Test Case 1:** Since there is only $1$ exercise, the maximum tension is equal to the tension provided by that exercise, i.e, $10$ units. \r\n\r\n**Test Case 2:** At time $t \u003d 10$, Chef has $10$ units of tension. \r\n\r\nFrom $t \u003d 10$ to $t \u003d 11$, his muscles releases $2$ unit of tension and at $t \u003d 11$, he further gains $10$ units of tension to have total of $10 - 2 + 10 \u003d 18$ units of tension.\r\n\r\nSo the maximum tension Chef feels in his muscles is $18$ units.\r\n\r\n**Test Case 3:** At time $t \u003d 1$, Chef has $1$ unit of tension. \r\n\r\nFrom $t \u003d 1$ to $t \u003d 2$, his muscles releases $1$ unit of tension and at $t \u003d 2$, he further gains $2$ units of tension to have total of $1 - 1 + 2 \u003d 2$ units of tension.\r\n\r\nFrom $t \u003d 2$ to $t \u003d 3$, his muscles releases $1$ unit of tension and at $t \u003d 3$, he further gains $3$ units of tension to have total of $2 - 1 + 3 \u003d 4$ units of tension. \r\n\r\nSo the maximum tension Chef feels in his muscles is $4$ units."}}]}