{"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\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cstyle type\u003d\u0027text/css\u0027\u003e .input, .output {border: 1px solid #888888;} .output {margin-bottom:1em;position:relative;top:-1px;} .output pre,.input pre {background-color:#EFEFEF;line-height:1.25em;margin:0;padding:0.25em;} .title {background-color:#FFFFFF;border-bottom: 1px solid #888888;font-family:arial;font-weight:bold;padding:0.25em;} \u003c/style\u003e \u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027]], displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027]]}\n });\n \u003c/script\u003e\n \u003cscript type\u003d\"text/javascript\" async\n src\u003d\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\"\u003e\n \u003c/script\u003e\n\u003cp\u003e \u003cspan class\u003d\"tex-font-style-bf\"\u003eNote that the memory limit is unusual.\u003c/span\u003e\u003c/p\u003e \n\u003cp\u003eYou are given a multiset consisting of $$$n$$$ integers. You have to process queries of two types:\u003c/p\u003e \n\u003cul\u003e \n \u003cli\u003e add integer $$$k$$$ into the multiset; \u003c/li\u003e \n \u003cli\u003e find the $$$k$$$-th order statistics in the multiset and remove it. \u003c/li\u003e\n\u003c/ul\u003e \n\u003cp\u003e$$$k$$$-th order statistics in the multiset is the $$$k$$$-th element in the sorted list of all elements of the multiset. For example, if the multiset contains elements $$$1$$$, $$$4$$$, $$$2$$$, $$$1$$$, $$$4$$$, $$$5$$$, $$$7$$$, and $$$k \u003d 3$$$, then you have to find the $$$3$$$-rd element in $$$[1, 1, 2, 4, 4, 5, 7]$$$, which is $$$2$$$. If you try to delete an element which occurs multiple times in the multiset, only one occurence is removed. \u003c/p\u003e \n\u003cp\u003eAfter processing all queries, print \u003cspan class\u003d\"tex-font-style-bf\"\u003eany\u003c/span\u003e number belonging to the multiset, or say that it is empty.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"UWAGA Limit pamięci to 28MB\n\n\u003cp\u003eThe first line contains two integers $$$n$$$ and $$$q$$$ ($$$1 \\le n, q \\le 10^6$$$) — the number of elements in the initial multiset and the number of queries, respectively.\u003c/p\u003e \n\u003cp\u003eThe second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$1 \\le a_1 \\le a_2 \\le \\dots \\le a_n \\le n$$$) — the elements of the multiset.\u003c/p\u003e \n\u003cp\u003eThe third line contains $$$q$$$ integers $$$k_1$$$, $$$k_2$$$, ..., $$$k_q$$$, each representing a query: \u003c/p\u003e \n\u003cul\u003e \n \u003cli\u003e if $$$1 \\le k_i \\le n$$$, then the $$$i$$$-th query is \"insert $$$k_i$$$ into the multiset\"; \u003c/li\u003e \n \u003cli\u003e if $$$k_i \u0026lt; 0$$$, then the $$$i$$$-th query is \"remove the $$$|k_i|$$$-th order statistics from the multiset\". For this query, it is guaranteed that $$$|k_i|$$$ is not greater than the size of the multiset. \u003c/li\u003e\n\u003c/ul\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eIf the multiset is empty after all queries, print $$$0$$$.\u003c/p\u003e \n\u003cp\u003eOtherwise, print any integer that belongs to the resulting multiset.\u003c/p\u003e"}},{"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\u003e5 5\n1 2 3 4 5\n-1 -1 -1 -1 -1\n\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\n\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 4\n1 2 3 4 5\n-5 -1 -3 -1\n\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\u003e3\n\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 2\n1 1 1 2 3 4\n5 6\n\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\u003e6\n\u003c/pre\u003e\n \u003c/div\u003e\n\u003c/div\u003e"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn the first example, all elements of the multiset are deleted.\u003c/p\u003e \n\u003cp\u003eIn the second example, the elements $$$5$$$, $$$1$$$, $$$4$$$, $$$2$$$ are deleted (they are listed in chronological order of their removal).\u003c/p\u003e \n\u003cp\u003eIn the third example, $$$6$$$ is not the only answer.\u003c/p\u003e"}}]}