CF73B.Need For Brake

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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!

nn racers take part in the championship, which consists of a number of races. After each race racers are arranged from place first to nn -th (no two racers share the same place) and first mm places are awarded. Racer gains bib_{i} points for ii -th awarded place, which are added to total points, obtained by him for previous races. It is known that current summary score of racer ii is aia_{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 nn ( 1<=n<=1051<=n<=10^{5} ) — number of racers. Each of the next nn lines contains sis_{i} and aia_{i} — nick of the racer (nonempty string, which consist of no more than 20 lowercase Latin letters) and the racer's points ( 0<=ai<=1060<=a_{i}<=10^{6} ). Racers are given in the arbitrary order.

The next line contains the number mm ( 0<=m<=n0<=m<=n ). Then mm nonnegative integer numbers bib_{i} follow. ii -th number is equal to amount of points for the ii -th awarded place ( 0<=bi<=1060<=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
首页