{"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\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 type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e你是一家大型企业的负责人。有$$$n$$$人在你手下工作,而$$$n$$$是奇数(即$$$n$$$不能被$$$2$$$整除)。\u003c/p\u003e\u003cp\u003e你需要给员工发放工资。最初,你有$$$s$$$美元用于发放工资,第$$$i$$$个员工的工资应在$$$l_i$$$到$$$r_i$$$美元之间。你必须以工资中位数尽可能大的方式进行发放。\u003c/p\u003e\u003cp\u003e要找到奇数长度序列的中位数,你需要对其进行排序,并取排序后中间位置的元素。例如:\u003c/p\u003e\u003cul\u003e \u003cli\u003e 序列$$$[5, 1, 10, 17, 6]$$$的中位数是$$$6$$$, \u003c/li\u003e\u003cli\u003e 序列$$$[1, 2, 1]$$$的中位数是$$$1$$$。 \u003c/li\u003e\u003c/ul\u003e\u003cp\u003e保证你有足够的钱支付最低工资,即$$$l_1 + l_2 + \\dots + l_n \\le s$$$。\u003c/p\u003e\u003cp\u003e\u003cspan class\u003d\"tex-font-style-bf\"\u003e注意,你不必在工资上花光所有的$$$s$$$美元。\u003c/span\u003e\u003c/p\u003e\u003cp\u003e你需要回答$$$t$$$个测试用例。\u003c/p\u003e"}},{"title":"输入","value":{"format":"HTML","content":"\u003cp\u003e第一行包含一个整数$$$t$$$($$$1 \\le t \\le 2 \\cdot 10^5$$$)— 测试用例的数量。\u003c/p\u003e\u003cp\u003e每个查询的第一行包含两个整数$$$n$$$和$$$s$$$($$$1 \\le n \u0026lt; 2 \\cdot 10^5$$$,$$$1 \\le s \\le 2 \\cdot 10^{14}$$$)— 员工数量和你拥有的金额。值$$$n$$$不能被$$$2$$$整除。\u003c/p\u003e\u003cp\u003e每个查询的接下来$$$n$$$行包含有关员工的信息。第$$$i$$$行包含两个整数$$$l_i$$$和$$$r_i$$$($$$1 \\le l_i \\le r_i \\le 10^9$$$)。\u003c/p\u003e\u003cp\u003e保证所有查询中所有$$$n$$$的总和不超过$$$2 \\cdot 10^5$$$。\u003c/p\u003e\u003cp\u003e还保证你有足够的钱支付每位员工的最低工资,即$$$\\sum\\limits_{i\u003d1}^{n} l_i \\le s$$$。\u003c/p\u003e"}},{"title":"输出","value":{"format":"HTML","content":"\u003cp\u003e对于每个测试用例,输出一个整数 — 你可以获得的最大中位数工资。\u003c/p\u003e"}},{"title":"示例 1","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\u003e3\n3 26\n10 12\n1 4\n10 11\n1 1337\n1 1000000000\n5 26\n4 4\n2 4\n6 8\n5 6\n2 7\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e11\n1337\n6\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"注意","value":{"format":"HTML","content":"\u003cp\u003e在第一个测试用例中,你可以按以下方式分配工资:$$$sal_1 \u003d 12, sal_2 \u003d 2, sal_3 \u003d 11$$$($$$sal_i$$$是第$$$i$$$个员工的工资)。然后中位数工资为$$$11$$$。\u003c/p\u003e\u003cp\u003e在第二个测试用例中,你必须支付$$$1337$$$美元给唯一的员工。\u003c/p\u003e\u003cp\u003e在第三个测试用例中,你可以按以下方式分配工资:$$$sal_1 \u003d 4, sal_2 \u003d 3, sal_3 \u003d 6, sal_4 \u003d 6, sal_5 \u003d 7$$$。然后中位数工资为$$$6$$$。\u003c/p\u003e"}}]}