P25452 [AtCoder] Falling Asleep
入门
题目描述

Problem Description

Niwango-kun created a playlist consisting of $ N $ songs. The $ i $-th song has a title $ s_i $ and a playback time of $ t_i $ seconds. It is guaranteed that $s_1, \ldots, s_N$ are distinct.

Niwango-kun was working while playing this playlist. (That is, all songs in the playlist were played once in order, without any pauses in between.) However, he dozed off during the work and woke up after all the songs had finished playing. From the records, it was known that Niwango-kun fell asleep at the timing when the song with the title $ X $ finished playing.

Determine the total number of seconds of song playback time that occurred while Niwango-kun was asleep.

Input Format

The input is given from the standard input in the following format:

$ N $ $ s_1 $ $ t_1 $ $\vdots$ $ s_{N} $ $ t_N $ $ X $

Output Format

Output the answer.

Sample Input and Output

Sample Input #1

3
dwango 2
sixth 5
prelims 25
dwango

Sample Output #1

30

Sample Input #2

1
abcde 1000
abcde

Sample Output #2

0

Sample Input #3

15
ypnxn 279
kgjgwx 464
qquhuwq 327
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
wunfagppcoi 200
dhavrncwfw 720
jpcmigg 658
wrczqxycivdqn 639
mcmkkbnjfeod 992
htqvkgkbhtytsz 130
twflegsjz 467
dswxxrxuzzfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu

Sample Output #3

6348

Notes/Hints

Constraints

  • $1 \leq N \leq 50$
  • $ s_i, X $ are strings of length between $ 1 $ and $ 100 $ consisting of lowercase English letters.
  • $s_1, \ldots, s_N$ are distinct.
  • There exists an integer $ i $ such that $ s_i = X $.
  • $1 \leq t_i \leq 1000$
  • $ t_i $ is an integer.

Sample Explanation 1

  • The songs played while Niwango-kun was asleep are sixth and prelims.
  • The sum of their playback times, which is $ 30 $, is the answer.

Sample Explanation 2

  • No songs were played while Niwango-kun was asleep.
  • The sum of the playback times is $ 0 $.
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 dwango 2 sixth 5 prelims 25 dwango
样例输出
30