{"trustable":false,"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集训队辩论赛正在进行,辩论选手只有两名——ZZJ和LYD。还有n名集训队队员想来围观,且每个人有一个影响力ai和一种观点。\n一共只有四种观点:\"00\":不支持任何候选人,\"10\":支持ZZJ而不支持LYD,\"01\":支持LYD而不支持ZZJ,\"11\":支持两名候选人。\u003c/p\u003e\n\u003cp\u003e主办方想邀请其中一些队员作为观众,但需同时满足两个条件:1.至少半数观众支持ZZJ;2.至少半数观众支持LYD。(半数是向上取整,比如一共有5名观众,那么至少有三人支持ZZJ,至少三人支持LYD)\n\u003c/p\u003e\n\u003cp\u003e你需要帮他们选择这样一组观众,且使所有观众的影响力之和尽可能大。\u003c/p\u003e\n"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003e第一行一个正整数n(1\u003c\u003dn\u003c\u003d400000),代表集训队人数。\n以下n行每行一个字符串s和一个正整数ai(1\u003c\u003dn\u003c\u003d5000),分别代表第i名队员的观点和影响力。\u003c/p\u003e\n"}},{"title":"Output","value":{"format":"HTML","content":"\n\u003cp\u003e输出一个整数,满足条件的一组观众的影响力之和的最大值,若无解则输出0。\u003c/p\u003e\n"}},{"title":"Examples","value":{"format":"HTML","content":"\u003cdiv class\u003d\"sample-test\"\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e6\u003cbr\u003e11 6\u003cbr\u003e10 4\u003cbr\u003e01 3\u003cbr\u003e00 3\u003cbr\u003e00 7\u003cbr\u003e00 9\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e22\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e5\u003cbr\u003e11 1\u003cbr\u003e01 1\u003cbr\u003e00 100\u003cbr\u003e10 1\u003cbr\u003e01 1\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e103\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e6\u003cbr\u003e11 19\u003cbr\u003e10 22\u003cbr\u003e00 18\u003cbr\u003e00 29\u003cbr\u003e11 29\u003cbr\u003e10 28\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e105\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e3\u003cbr\u003e00 5000\u003cbr\u003e00 5000\u003cbr\u003e00 5000\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e0\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n\u003c/div\u003e"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn the first example $$$4$$$ spectators can be invited to maximize total influence: $$$1$$$, $$$2$$$, $$$3$$$ and $$$6$$$. Their political views are: \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e11\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e10\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e01\u003c/span\u003e\" and \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e00\u003c/span\u003e\". So in total $$$2$$$ out of $$$4$$$ spectators support Alice and $$$2$$$ out of $$$4$$$ spectators support Bob. The total influence is $$$6+4+3+9\u003d22$$$.\u003c/p\u003e\n\u003cp\u003eIn the second example the direction can select all the people except the $$$5$$$-th person.\u003c/p\u003e\n\u003cp\u003eIn the third example the direction can select people with indices: $$$1$$$, $$$4$$$, $$$5$$$ and $$$6$$$.\u003c/p\u003e\n\u003cp\u003eIn the fourth example it is impossible to select any non-empty set of spectators.\u003c/p\u003e"}}]}