#P8086. 『JROI-5』Music
『JROI-5』Music
Background
Please note the unusual time limit.
This problem has a large input size, so it is recommended to use a fast input method.
Little C needs to spend money on Boss Ding every year.
Problem Description
Little C likes listening to music on NetEase Cloud Music, and she wants you to help her calculate her total listening time on NetEase Cloud Music.
Little C has listening records. Each record is in the form x t, which means Little C listened to the song with id for minutes. The listening time is the sum of over all valid records.
First, if a record has , then this record is invalid.
Second, for any given song, only the first valid record will be counted. After that, repeated records of listening to the same song will not be added to the listening time.
Input Format
The first line contains a positive integer , as described.
The next lines each contain two positive integers , representing one listening record.
Output Format
Output one integer on one line, representing the listening time.
5
1 114514
2 1
2 1919180
1 10
3 2
2033696
见附件
见附件
Hint
[Sample Explanation]
The 1st record: 1 114514, a valid record, can be counted.
The 2nd record: 2 1, , an invalid record.
The 3rd record: 2 1919180, a valid record, can be counted.
The 4th record: 1 10, the song with id has already been counted in the 1st record. This record is valid, but cannot be counted.
The 5th record: 3 2, a valid record, can be counted.
So the answer is .
For of the testdata, it is guaranteed that .
For of the testdata, it is guaranteed that and .
Translated by ChatGPT 5