#72. 跳过特定区间求和

    ID: 72 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatArray-2gesp2模拟循环结构

跳过特定区间求和

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 66, he must ignore all numbers from 66 up to and including the next 77. 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 66 and extending to the next 77 (inclusive of both 66 and 77). It is guaranteed that every 66 will be followed by at least one 77. If the array contains no numbers, return 00.

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 66s or 77s in the array, so the sum is 1+2+2=51 + 2 + 2 = 5.

Sample 2: [1 2 2 6 99 99 7]. The section from the first 66 to the next 77 (i.e., 6 99 99 7) is ignored. Thus, the sum is 1+2+2=51 + 2 + 2 = 5.

Sample 3: [1 1 6 7 2]. The section from 66 to 77 (i.e., 6 7) is ignored. Thus, the sum is 1+1+2=41 + 1 + 2 = 4.

Constraints

Time limit: 11 second, Memory limit: 10241024 KiB for each test case.