{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003ePolar Bear Pitching helps you crystallize your message. \u003cbr\u003e The stage could not be any cooler, and we mean literally: \u003cbr\u003e a hole cut through the ice in the frozen Baltic Sea.\u003cbr\u003e\u003cbr\u003e2050有一项很有挑战的活动 —— Polar Bear Pitching 。\u003cbr\u003e体验人跳入冰水中讲述自己的恐惧,改变以及梦想。这是没有时间限制的演讲,就看你能在冰水中呆多久!\u003cbr\u003e\u003cbr\u003e现在,我们要依次面对 $n$ 个冰水挑战,每个挑战你都可以选择接受或不接受。接受第 $i$ 个挑战会让你丧失 $a_i$点体力,因为每个挑战所处的环境不同,如果你要挑战它,在挑战它之前你的体力 $x$ 会变成 $\\min(x,b_i)$,当你完成这个挑战的时候,你的体力会变成 $x-a_i$,体力任何时候不允许小于等于 $0$,无论你是否接受第 $i$ 个挑战,在这个挑战结束以后你的体力都会增加 $c_i$。\u003cbr\u003e\u003cbr\u003e现在我们想知道最多可以完成多少个挑战。\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"第一行一个正整数 $T~(T\\leq 50)$ 表示数据组数。\u003cbr\u003e\u003cbr\u003e接下来 $T$ 组数据,每组第一行两个正整数 $n,c~(1\\leq n\\leq 10^3,1\\leq c\\leq 10^9)$,表示挑战的数量和初始体力,接下来 $n$ 行,每行三个非负整数 $a_i,b_i,c_i (0\\leq a_i,b_i,c_i\\leq 10^9)$。"}},{"title":"Output","value":{"format":"HTML","content":"对于每组数据输出一行一个数,表示你最多能完成几个挑战。"}},{"title":"Sample","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\u003e2\r\n3 10\r\n1 2 0\r\n4 8 3\r\n6 10 1\r\n2 1\r\n1 1 1\r\n1 1 1\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\n0\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}