QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 256 MB مجموع النقاط: 100 قابلة للهجوم ✓

#13507. Handicapped Onsite Prediction

الإحصائيات

你认为赢得比赛很容易吗?当周围有那么多不可思议的对手时,情况就并非如此了。

你正在参加 OpenBowl 编程竞赛。它由两轮组成 —— 网络赛和现场赛。除了你之外,还有 $N - 1$ 名渴望获胜的竞争对手。这 $N$ 名参赛者都已经参加了网络赛,参赛者 $i$ 恰好获得了 $A_i$ 分(你完全不知道这些分数是如何计算出来的 —— 只有主主办方 Sn. 知道这一切;你只听说这与有条件不计分的轮次有关)。

现在是现场赛的时间了。在现场赛中,每位参赛者都会获得 $1$ 到 $N$ 之间(含边界)的某个名次,且没有两位参赛者会获得相同的名次。在现场赛中获得第 $j$ 名的参赛者将被授予 $P_j$ 分,参赛者的最终总分等于其在网络赛和现场赛中获得的分数之和。然后计算每位参赛者的最终名次 —— 对于参赛者 $i$,其最终名次等于 $k + 1$,其中 $k$ 是最终总分严格大于参赛者 $i$ 的参赛者人数。

你清楚地知道你的对手非常强大。这就是为什么你甚至不以赢得比赛为目标。你决定,如果最终获得的最终名次不低于 $X$(即名次数值 $\le X$),你就会对自己的成绩感到满意。现在你想知道:为了保证这一点,你在现场赛中需要获得的最低(最靠后)名次是多少?

输入格式

输入包含两个整数 $N$ 和 $X$ ($1 \le X \le N \le 10^5$),接着是 $N$ 个整数 $A_i$ —— 参赛者 $i$ 在网络赛中获得的分数,然后是 $N$ 个整数 $P_j$ —— 在现场赛中获得第 $j$ 名的参赛者所获得的分数 ($0 \le A_i, P_j \le 10^9$)。保证对于任意 $1 \le j < N$,有 $P_j \ge P_{j+1}$。你是 1 号参赛者。

输出格式

输出一个介于 $1$ 和 $N$ 之间(含边界)的整数 —— 为了保证最终总名次不低于 $X$(即名次数值 $\le X$),你在现场赛中需要获得的最低(最靠后)名次;如果即使在现场赛中获得第一名也无法保证,则输出 $-1$。

样例

输入样例 1

5 3
230 310 200 260 180
100 80 60 50 45

输出样例 1

2

输入样例 2

5 2
230 310 200 260 180
100 80 60 50 45

输出样例 2

-1

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.