A8749 | Olympiad
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
A boy named Vasya has taken part in an Olympiad. His teacher knows that in total Vasya got at least $x$ points for both tours of the Olympiad. The teacher has the results of the first and the second tour of the Olympiad but the problem is, the results have only points, no names. The teacher has to know Vasya's chances.
Help Vasya's teacher, find two numbers — the best and the worst place Vasya could have won. Note that the total results' table sorts the participants by the sum of points for both tours (the first place has the participant who has got the most points). If two or more participants have got the same number of points, it's up to the jury to assign places to them according to their choice. It is guaranteed that each participant of the Olympiad participated in both tours of the Olympiad.
Help Vasya's teacher, find two numbers — the best and the worst place Vasya could have won. Note that the total results' table sorts the participants by the sum of points for both tours (the first place has the participant who has got the most points). If two or more participants have got the same number of points, it's up to the jury to assign places to them according to their choice. It is guaranteed that each participant of the Olympiad participated in both tours of the Olympiad.
输入格式
The first line contains two space-separated integers $n,x$ ( $1<=n<=10^{5}; 0<=x<=2·10^{5}$ ) — the number of Olympiad participants and the minimum number of points Vasya earned.
The second line contains $n$ space-separated integers: $a_{1},a_{2},...,a_{n}$ ( $0<=a_{i}<=10^{5}$ ) — the participants' points in the first tour.
The third line contains $n$ space-separated integers: $b_{1},b_{2},...,b_{n}$ ( $0<=b_{i}<=10^{5}$ ) — the participants' points in the second tour.
The participants' points are given in the arbitrary order. It is guaranteed that Vasya was present in the Olympiad — there are two integers $i,j$ $(1<=i,j<=n)$ such, that $a_{i}+b_{j}>=x$ .
The second line contains $n$ space-separated integers: $a_{1},a_{2},...,a_{n}$ ( $0<=a_{i}<=10^{5}$ ) — the participants' points in the first tour.
The third line contains $n$ space-separated integers: $b_{1},b_{2},...,b_{n}$ ( $0<=b_{i}<=10^{5}$ ) — the participants' points in the second tour.
The participants' points are given in the arbitrary order. It is guaranteed that Vasya was present in the Olympiad — there are two integers $i,j$ $(1<=i,j<=n)$ such, that $a_{i}+b_{j}>=x$ .
输出格式
Print two space-separated integers — the best and the worst place Vasya could have got on the Olympiad.
输入输出样例
输入 #1
5 2 1 1 1 1 1 1 1 1 1 1
输出 #1
1 5
输入 #2
6 7 4 3 5 6 4 4 8 6 0 4 3 4
输出 #2
1 5
In the first text sample all 5 participants earn 2 points each in any case. Depending on the jury's decision, Vasya can get the first (the best) as well as the last (the worst) fifth place.
In the second test sample in the best case scenario Vasya wins again: he can win 12 points and become the absolute winner if the total results' table looks like that — {4:8, 6:4, 3:6, 4:4, 4:3, 5:0}.
In this table all participants are sorted by decreasing points and we can see how much a participant earned in the first and in the second tour.
In the worst case scenario Vasya can get the fifth place if the table looks like that — {4:8, 4:6, 6:4, 5:4, 4:3, 3:0}, and he earned 4 and 3 points in the first and second tours, correspondingly.
In the second test sample in the best case scenario Vasya wins again: he can win 12 points and become the absolute winner if the total results' table looks like that — {4:8, 6:4, 3:6, 4:4, 4:3, 5:0}.
In this table all participants are sorted by decreasing points and we can see how much a participant earned in the first and in the second tour.
In the worst case scenario Vasya can get the fifth place if the table looks like that — {4:8, 4:6, 6:4, 5:4, 4:3, 3:0}, and he earned 4 and 3 points in the first and second tours, correspondingly.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted