#K57712. Total Playback Length Calculation

    ID: 30482 Type: Default 1000ms 256MiB

Total Playback Length Calculation

Total Playback Length Calculation

You are given a playlist, where each segment is defined by its duration (in seconds) and a flag indicating whether it is an advertisement. Advertisement segments (flag 1) should be excluded from the total playback length.

The input starts with an integer n representing the number of segments. This is followed by n lines, each containing two integers: the duration of the segment and a flag (0 for a normal segment, 1 for an advertisement).

Mathematically, if the playlist is \(\{(d_1, f_1), (d_2, f_2), \dots, (d_n, f_n)\}\), then the answer is \(\sum_{i=1}^n d_i\) for all segments where \(f_i=0\). Your task is to compute and output this total playback length.

inputFormat

The first line contains an integer (n) ((1 \le n \le 10^5)) representing the number of segments in the playlist. Each of the following (n) lines contains two integers: (duration) ((0 \le duration \le 10^9)) and (flag) (where 0 indicates a normal segment and 1 indicates an advertisement).

outputFormat

Output a single integer that represents the total playback length in seconds, excluding advertisement segments.## sample

3
300 0
450 0
180 0
930

</p>