300384: CF73B. Need For Brake

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

Description

Need For Brake

题意翻译

$n$ 名参赛者参加锦标赛,其中包括许多比赛。每次比赛后,参赛者从第一名到第$n$ 名(没有并列)和第一个$m$ 的位置被授予。赛车手获得第$i$ 个奖励的位置的$b{i}$ 积分,该积分加上他在前几场比赛中获得的总积分。已知赛车手$i$ 目前的总分是$a{i}$ 分。在冠军赛的最后一站,所有参赛者将按积分的降序排列。分数相等的赛车手通过按字典顺序增加名字来排序。 不幸的是,冠军赛已经结束了,只剩下一场比赛了。Vasya 决定找出他能在冠军赛中占据的最高和最低位置。

题目描述

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.

输入输出格式

输入格式


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.

输出格式


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

Input

题意翻译

$n$ 名参赛者参加锦标赛,其中包括许多比赛。每次比赛后,参赛者从第一名到第$n$ 名(没有并列)和第一个$m$ 的位置被授予。赛车手获得第$i$ 个奖励的位置的$b{i}$ 积分,该积分加上他在前几场比赛中获得的总积分。已知赛车手$i$ 目前的总分是$a{i}$ 分。在冠军赛的最后一站,所有参赛者将按积分的降序排列。分数相等的赛车手通过按字典顺序增加名字来排序。 不幸的是,冠军赛已经结束了,只剩下一场比赛了。Vasya 决定找出他能在冠军赛中占据的最高和最低位置。

加入题单

算法标签: