CF73B.Need For Brake

普及+/提高

通过率:0%

时间限制:4.00s

内存限制:256MB

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!

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.

瓦西娅正在玩《速度与激情》(Need For Brake)。他之所以玩这款游戏,是因为生日时收到了一个全新的电脑方向盘!现在他确信自己将在最喜爱的赛车类电脑游戏锦标赛中夺得冠军!

共有 nn 名车手参加该锦标赛,锦标赛由若干场比赛组成。每场比赛结束后,所有车手按名次从第 11 名到第 nn 名进行排序(不存在并列名次),且前 mm 名获得奖励。获得第 ii 名奖励的车手将得到 bib_i 分,这些分数将累加至其此前各场比赛所得总分中。已知车手 ii 当前的累计得分为 aia_i 分。锦标赛最终排名将依据所有车手的总得分从高到低排序;若总得分相同,则按姓名字典序升序排列。

不幸的是,锦标赛已接近尾声,仅剩最后一场比赛尚未进行。瓦西娅决定计算出:在最后一场比赛结束后,他所能取得的最高名次与最低名次分别是多少。

输入格式

The first line contains number n (1 ≤ n ≤ 105) — 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 ≤ 106). 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 ≤ 106).

The last line contains Vasya's racer nick.

第一行包含一个整数 nn(1≤n≤1051 \leq n \leq 10^5)——参赛选手的数量。接下来的 nn 行每行包含 sis_i 和 aia_i —— 选手的昵称(非空字符串,仅由至多 20 个小写拉丁字母组成)以及该选手的得分(0≤ai≤1060 \leq a_i \leq 10^6)。选手以任意顺序给出。

下一行包含一个整数 mm(0≤m≤n0 \leq m \leq n)。随后是 mm 个非负整数 bib_i。第 ii 个数表示第 ii 名所对应的奖励分数(0≤bi≤1060 \leq b_i \leq 10^6)。

最后一行包含 Vasya 所支持选手的昵称。

输出格式

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

输入解题思路,AI测评打分。不知道怎么写?

首页