atcoder#DWACON6THPRELIMSA. Falling Asleep
Falling Asleep
Score : points
Problem Statement
Niwango created a playlist of songs. The title and the duration of the -th song are and seconds, respectively. It is guaranteed that are all distinct.
Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.) However, he fell asleep during his work, and he woke up after all the songs were played. According to his record, it turned out that he fell asleep at the very end of the song titled .
Find the duration of time when some song was played while Niwango was asleep.
Constraints
- and are strings of length between and (inclusive) consisting of lowercase English letters.
- are distinct.
- There exists an integer such that .
- is an integer.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
3
dwango 2
sixth 5
prelims 25
dwango
30
- While Niwango was asleep, two songs were played:
sixth
andprelims
. - The answer is the total duration of these songs, .
1
abcde 1000
abcde
0
- No songs were played while Niwango was asleep.
- In such a case, the total duration of songs is .
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
6348