305527: CF1046C. Space Formula

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Space Formula

题意翻译

#### 大意: 有$N ( 1 \leq N \leq 200000 )$个人,每个人都有一个与其他任何人不同的数字$S_{k}( 0 \leq S_k \leq 10^8,k=1 \dots N )$。现给出一数列$P$,让每个人任意取走一个$P_{k}( 0 \leq P_k \leq 10^8,k=1 \dots N )$加在原数值上。 求:原排名为$D( 1 \leq D \leq N )$的人取数所能获得的最靠前的排名 **输入:** 第一行:$N,D$ 第二行:$S$ 第三行:$P$ (保证$S,P$是单调不上升的数列) **输出** 最优秀的排名

题目描述

Formula 1 officials decided to introduce new competition. Cars are replaced by space ships and number of points awarded can differ per race. Given the current ranking in the competition and points distribution for the next race, your task is to calculate the best possible ranking for a given astronaut after the next race. It's guaranteed that given astronaut will have unique number of points before the race.

输入输出格式

输入格式


The first line contains two integer numbers $ N $ ( $ 1 \leq N \leq 200000 $ ) representing number of F1 astronauts, and current position of astronaut $ D $ ( $ 1 \leq D \leq N $ ) you want to calculate best ranking for (no other competitor will have the same number of points before the race). The second line contains $ N $ integer numbers $ S_k $ ( $ 0 \leq S_k \leq 10^8 $ , $ k=1...N $ ), separated by a single space, representing current ranking of astronauts. Points are sorted in non-increasing order. The third line contains $ N $ integer numbers $ P_k $ ( $ 0 \leq P_k \leq 10^8 $ , $ k=1...N $ ), separated by a single space, representing point awards for the next race. Points are sorted in non-increasing order, so winner of the race gets the maximum number of points.

输出格式


Output contains one integer number — the best possible ranking for astronaut after the race. If multiple astronauts have the same score after the race, they all share the best ranking.

输入输出样例

输入样例 #1

4 3
50 30 20 10
15 10 7 3

输出样例 #1

2

说明

If the third ranked astronaut wins the race, he will have 35 points. He cannot take the leading position, but he can overtake the second position if the second ranked astronaut finishes the race at the last position.

Input

题意翻译

#### 大意: 有$N ( 1 \leq N \leq 200000 )$个人,每个人都有一个与其他任何人不同的数字$S_{k}( 0 \leq S_k \leq 10^8,k=1 \dots N )$。现给出一数列$P$,让每个人任意取走一个$P_{k}( 0 \leq P_k \leq 10^8,k=1 \dots N )$加在原数值上。 求:原排名为$D( 1 \leq D \leq N )$的人取数所能获得的最靠前的排名 **输入:** 第一行:$N,D$ 第二行:$S$ 第三行:$P$ (保证$S,P$是单调不上升的数列) **输出** 最优秀的排名

加入题单

上一题 下一题 算法标签: