eolymp
bolt
Try our new interface for solving problems
Problems

Handicapped Onsite Prediction

Handicapped Onsite Prediction

Do you think that winning a competition is easy? This is not the case when there are so many incredible competitors around. You're taking part in the OpenBowl programming contest. It consists of two rounds - online round and onsite round. Besides you, there are \textbf{N}-\textbf{1} more competitors eager to win. Each of \textbf{N} competitors has already taken part in the online round, and competitor \textbf{i} received exactly \textbf{A_i} points (you have no idea about how these numbers were calculated - only Sn., the main contest organizer, knows everything about that; you've only heard that it had something to do with conditionally unrated rounds). Now it's time for the onsite round. At the onsite round every competitor takes some place between \textbf{1} and \textbf{N}, inclusive, and no two contestants take the same place. For place \textbf{j} at the onsite round \textbf{P_j} points are awarded, and the final score of the contestant is equal to the sum of points received by him during the online and the onsite rounds. Then each competitor's final place is calculated - for competitor \textbf{i} it is equal to \textbf{k}+\textbf{1}, where \textbf{k} is the number of competitors whose final score is strictly greater than that of competitor \textbf{i}. You clearly understand that your rivals are very strong. That's why you aren't even aiming at winning the contest. You decided that you will be pleased with your result if the final place you take is not lower than \textbf{X}. Now you would like to find out: what is the lowest place at the onsite round you should take to guarantee that? \InputFile Contains two integer numbers \textbf{N} and \textbf{X} (\textbf{1} ≤ \textbf{X} ≤ \textbf{N} ≤ \textbf{10^5}), followed by \textbf{N} integer numbers \textbf{A_i} - the number of points competitor \textbf{i} received during the online round, followed by \textbf{N} integer numbers \textbf{P_j} - the number of points received by the competitor who takes place \textbf{j} at the onsite round (\textbf{0} ≤ \textbf{A_i}, \textbf{P_j} ≤ \textbf{10^9}). It is guaranteed that \textbf{P_j} ≥ \textbf{P_\{j+1\}} for any \textbf{j}, \textbf{1} ≤ \textbf{j} < \textbf{N}. You are competitor number \textbf{1}. \OutputFile Print one integer number between \textbf{1} and \textbf{N}, inclusive - the lowest place at the onsite round you should take in order to guarantee taking place \textbf{X} or higher overall, or \textbf{-1} if it is impossible to have such a guarantee even in case of winning the onsite round.
Time limit 2 seconds
Memory limit 256 MiB
Input example #1
5 3
230 310 200 260 180
100 80 60 50 45
Output example #1
2
Author Gennady Korotkevich
Source Gennady Korotkevich Contest 1, Petrozavodsk Training Camp, Day 1, Friday, August 23, 2013