{"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\"\u003e有一堆 n 根木棍。每根木棍的长度和重量都是预先知道的。这些木棍需要通过木工机器逐个加工。机器需要一些时间来准备加工木棍,这段时间被称为准备时间。准备时间与机器中的清洁操作和更换工具和形状有关。木工机器的准备时间如下:\u003cbr\u003e\u003cbr\u003e(a) 第一根木棍的准备时间为1分钟。\u003cbr\u003e(b) 在加工长度为 l 和重量为 w 的木棍后,如果下一根木棍的长度为 l\u0027 且重量为 w\u0027,且满足 l\u0027≥l 且 w\u0027≥w,则不需要准备时间。否则,需要1分钟的准备时间。\u003cbr\u003e\u003cbr\u003e你需要找出加工给定数量的木棍所需的最小准备时间。例如,如果有五根木棍,它们的长度和重量分别为 (4,9), (5,2), (2,1), (3,5), 和 (1,4),那么最小准备时间应该是2分钟,因为存在一个顺序为 (1,4), (3,5), (4,9), (2,1), (5,2) 的木棍序列。\u003cbr\u003e\u003c/div\u003e"}},{"title":"输入","value":{"format":"HTML","content":"输入包含 T 个测试用例。输入文件的第一行给出测试用例的数量 T。每个测试用例包括两行:第一行包含一个整数 n,表示测试用例中木棍的数量,满足 1≤n≤5000;第二行包含 n 对正整数 l1, w1, l2, w2, ..., ln, wn,每个数的绝对值不超过10000,其中 li 和 wi 分别表示第 i 根木棍的长度和重量。这 2n 个整数由一个或多个空格分隔。\u003cbr\u003e"}},{"title":"输出","value":{"format":"HTML","content":"输出应包含每行一个最小准备时间(以分钟为单位)。\u003cbr\u003e"}},{"title":"样例","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 \r\n5 \r\n4 9 5 2 2 1 3 5 1 4 \r\n3 \r\n2 2 1 1 2 2 \r\n3 \r\n1 3 2 2 3 1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\n1\r\n3\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}}]}