#72. 跳过特定区间求和
跳过特定区间求和
Sum with Ignored Sections
Background
Congcong is processing a list of integers. He needs to calculate the sum of these numbers, but with a special rule: if he encounters the number , he must ignore all numbers from up to and including the next . Congcong asks for your help to write a program to complete this task.
Problem Description
Calculate the sum of numbers in an array, but ignore sections of numbers starting with a and extending to the next (inclusive of both and ). It is guaranteed that every will be followed by at least one . If the array contains no numbers, return .
Input Format
Input is given from standard input in the following format.
nums(an array of integers)
Output Format
Output is printed to standard output in the following format.
sum(the calculated sum)
Sample
[1 2 2]
5
[1 2 2 6 99 99 7]
5
[1 1 6 7 2]
4
Sample Explanation
Sample 1: [1 2 2]. There are no s or s in the array, so the sum is .
Sample 2: [1 2 2 6 99 99 7]. The section from the first to the next (i.e., 6 99 99 7) is ignored. Thus, the sum is .
Sample 3: [1 1 6 7 2]. The section from to (i.e., 6 7) is ignored. Thus, the sum is .
Constraints
Time limit: second, Memory limit: KiB for each test case.