{"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\"\u003eAs a fan of Doudizhu, WYJ likes collecting playing cards very much. \u003cbr\u003eOne day, MJF takes a stack of cards and talks to him: let\u0027s play a game and if you win, you can get all these cards. MJF randomly assigns these cards into $n$ heaps, arranges in a row, and sets a value on each heap, which is called \"penalty value\".\u003cbr\u003eBefore the game starts, WYJ can move the foremost heap to the end any times. \u003cbr\u003eAfter that, WYJ takes the heap of cards one by one, each time he needs to move all cards of the current heap to his hands and face them up, then he turns over some cards and the number of cards he turned is equal to the $penalty value$.\u003cbr\u003eIf at one moment, the number of cards he holds which are face-up is less than the $penalty value$, then the game ends. And WYJ can get all the cards in his hands (both face-up and face-down).\u003cbr\u003eYour task is to help WYJ maximize the number of cards he can get in the end.So he needs to decide how many heaps that he should move to the end before the game starts. Can you help him find the answer?\u003cbr\u003eMJF also guarantees that the sum of all \"penalty value\" is exactly equal to the number of all cards.\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"There are about $10$ test cases ending up with EOF.\u003cbr\u003eFor each test case:\u003cbr\u003ethe first line is an integer $n$ ($1\\leq n\\leq 10^6$), denoting $n$ heaps of cards;\u003cbr\u003enext line contains $n$ integers, the $i$$th$ integer $a_i$ ($0\\leq ai\\leq 1000$) denoting there are $a_i$ cards in $i$$th$ heap;\\\\then the third line also contains $n$ integers, the $i$$th$ integer $b_i$ ($1\\leq bi\\leq 1000$) denoting the \"penalty value\" of $i$$th$ heap is $b_i$.\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, print only an integer, denoting the number of piles WYJ needs to move before the game starts. If there are multiple solutions, print the smallest one.\u003cbr\u003e"}},{"title":"Sample","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\u003e5\r\n4 6 2 8 4\r\n1 5 7 9 2\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cbr\u003e\u003cpre\u003e\u003cbr\u003eFor the sample input:\u003cbr\u003e\u003cbr\u003e+ If WYJ doesn\u0027t move the cards pile, when the game starts the state of cards is:\u003cbr\u003e\u0026nbsp;\u0026nbsp;4 6 2 8 4\u003cbr\u003e\u0026nbsp;\u0026nbsp;1 5 7 9 2\u003cbr\u003eWYJ can take the first three piles of cards, and during the process, the number of face-up cards is 4-1+6-5+2-7. Then he can\u0027t pay the the \"penalty value\" of the third pile, the game ends. WYJ will get 12 cards.\u003cbr\u003e+ If WYJ move the first four piles of cards to the end, when the game starts the state of cards is:\u003cbr\u003e\u0026nbsp;\u0026nbsp;4 4 6 2 8\u003cbr\u003e\u0026nbsp;\u0026nbsp;2 1 5 7 9\u003cbr\u003eWYJ can take all the five piles of cards, and during the process, the number of face-up cards is 4-2+4-1+6-5+2-7+8-9. Then he takes all cards, the game ends. WYJ will get 24 cards.\u003cbr\u003e\u003cbr\u003eIt can be improved that the answer is 4.\u003cbr\u003e\u003cbr\u003e**huge input, please use fastIO.**\u003cbr\u003e\u003c/pre\u003e\u003cbr\u003e"}}]}