A8140 | Need For Brake
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Vasya plays the Need For Brake. He plays because he was presented with a new computer wheel for birthday! Now he is sure that he will win the first place in the championship in his favourite racing computer game!
$n$ racers take part in the championship, which consists of a number of races. After each race racers are arranged from place first to $n$ -th (no two racers share the same place) and first $m$ places are awarded. Racer gains $b_{i}$ points for $i$ -th awarded place, which are added to total points, obtained by him for previous races. It is known that current summary score of racer $i$ is $a_{i}$ points. In the final standings of championship all the racers will be sorted in descending order of points. Racers with an equal amount of points are sorted by increasing of the name in lexicographical order.
Unfortunately, the championship has come to an end, and there is only one race left. Vasya decided to find out what the highest and lowest place he can take up as a result of the championship.
$n$ racers take part in the championship, which consists of a number of races. After each race racers are arranged from place first to $n$ -th (no two racers share the same place) and first $m$ places are awarded. Racer gains $b_{i}$ points for $i$ -th awarded place, which are added to total points, obtained by him for previous races. It is known that current summary score of racer $i$ is $a_{i}$ points. In the final standings of championship all the racers will be sorted in descending order of points. Racers with an equal amount of points are sorted by increasing of the name in lexicographical order.
Unfortunately, the championship has come to an end, and there is only one race left. Vasya decided to find out what the highest and lowest place he can take up as a result of the championship.
输入格式
The first line contains number $n$ ( $1<=n<=10^{5}$ ) — number of racers. Each of the next $n$ lines contains $s_{i}$ and $a_{i}$ — nick of the racer (nonempty string, which consist of no more than 20 lowercase Latin letters) and the racer's points ( $0<=a_{i}<=10^{6}$ ). Racers are given in the arbitrary order.
The next line contains the number $m$ ( $0<=m<=n$ ). Then $m$ nonnegative integer numbers $b_{i}$ follow. $i$ -th number is equal to amount of points for the $i$ -th awarded place ( $0<=b_{i}<=10^{6}$ ).
The last line contains Vasya's racer nick.
The next line contains the number $m$ ( $0<=m<=n$ ). Then $m$ nonnegative integer numbers $b_{i}$ follow. $i$ -th number is equal to amount of points for the $i$ -th awarded place ( $0<=b_{i}<=10^{6}$ ).
The last line contains Vasya's racer nick.
输出格式
Output two numbers — the highest and the lowest place Vasya can take up as a result of the championship.
输入输出样例
输入 #1
3 teama 10 teamb 20 teamc 40 2 10 20 teama
输出 #1
2 3
输入 #2
2 teama 10 teamb 10 2 10 10 teamb
输出 #2
2 2
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted