{"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\u003eMonocarp有一个序列$$$a$$$,包含$$$n + m$$$个整数$$$a_1, a_2, \\dots, a_{n + m}$$$。他把这些元素分成了红色和蓝色两种颜色;$$$n$$$个元素被涂成了红色,其他的$$$m$$$个元素被涂成了蓝色。\u003c/p\u003e\u003cp\u003e在涂完颜色后,他写下了两个序列$$$r_1, r_2, \\dots, r_n$$$和$$$b_1, b_2, \\dots, b_m$$$。序列$$$r$$$包含了原序列中所有红色元素,$$$a$$$ \u003cspan class\u003d\"tex-font-style-bf\"\u003e按照它们在$$$a$$$中出现的顺序\u003c/span\u003e;同样地,序列$$$b$$$包含了原序列中所有蓝色元素,\u003cspan class\u003d\"tex-font-style-bf\"\u003e按照它们在$$$a$$$中出现的顺序\u003c/span\u003e。\u003c/p\u003e\u003cp\u003e不幸的是,原始序列丢失了,Monocarp只有序列$$$r$$$和$$$b$$$。他想要恢复原始序列。如果有多种恢复方式,他希望选择一种方式来最大化\u003c/p\u003e\u003cp\u003e$$$$$$f(a) \u003d \\max(0, a_1, (a_1 + a_2), (a_1 + a_2 + a_3), \\dots, (a_1 + a_2 + a_3 + \\dots + a_{n + m}))$$$$$$的值。\u003c/p\u003e\u003cp\u003e帮助Monocarp计算$$$f(a)$$$的最大可能值。\u003c/p\u003e"}},{"title":"输入","value":{"format":"HTML","content":"\u003cp\u003e第一行包含一个整数$$$t$$$($$$1 \\le t \\le 1000$$$)— 测试用例的数量。然后是测试用例。每个测试用例包括四行。\u003c/p\u003e\u003cp\u003e每个测试用例的第一行包含一个整数$$$n$$$($$$1 \\le n \\le 100$$$)。\u003c/p\u003e\u003cp\u003e第二行包含$$$n$$$个整数$$$r_1, r_2, \\dots, r_n$$$($$$-100 \\le r_i \\le 100$$$)。\u003c/p\u003e\u003cp\u003e第三行包含一个整数$$$m$$$($$$1 \\le m \\le 100$$$)。\u003c/p\u003e\u003cp\u003e第四行包含$$$m$$$个整数$$$b_1, b_2, \\dots, b_m$$$($$$-100 \\le b_i \\le 100$$$)。\u003c/p\u003e"}},{"title":"输出","value":{"format":"HTML","content":"\u003cp\u003e对于每个测试用例,输出一个整数 — $$$f(a)$$$的最大可能值。\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\u003e4\n4\n6 -5 7 -3\n3\n2 3 -4\n2\n1 1\n4\n10 -3 2 2\n5\n-1 -2 -3 -4 -5\n5\n-1 -2 -3 -4 -5\n1\n0\n1\n0\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e13\n13\n0\n0\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在示例测试用例的解释中,红色元素标记为\u003cspan class\u003d\"tex-font-style-bf\"\u003e粗体\u003c/span\u003e。\u003c/p\u003e\u003cp\u003e在第一个测试用例中,一个可能的序列$$$a$$$是$$$[\\mathbf{6}, 2, \\mathbf{-5}, 3, \\mathbf{7}, \\mathbf{-3}, -4]$$$。\u003c/p\u003e\u003cp\u003e在第二个测试用例中,一个可能的序列$$$a$$$是$$$[10, \\mathbf{1}, -3, \\mathbf{1}, 2, 2]$$$。\u003c/p\u003e\u003cp\u003e在第三个测试用例中,一个可能的序列$$$a$$$是$$$[\\mathbf{-1}, -1, -2, -3, \\mathbf{-2}, -4, -5, \\mathbf{-3}, \\mathbf{-4}, \\mathbf{-5}]$$$。\u003c/p\u003e\u003cp\u003e在第四个测试用例中,一个可能的序列$$$a$$$是$$$[0, \\mathbf{0}]$$$。\u003c/p\u003e"}}]}