[Huawei OD machine test 2023 B volume | 100 points] Street lighting problems (C++ Java JavaScript Python)

topic description

N street lights are installed on a straight road, starting from position 0, and the distance between street lights is fixed at 100 meters.
Each street light has its own lighting radius, please calculate the sum of the lengths of the intervals that cannot be illuminated between the first street light and the last street light.

enter description

The first line is a number N, indicating the number of street lamps, 1<=N<=100000, the
second line is a number separated by N spaces, indicating the lighting radius of the street light, 1<=illumination radius<=100000*100

output description

Between the first street lamp and the last street lamp, the length of the section that cannot be illuminated and

Example

enter 2
50 50
output 0
illustrate Streetlight 1 covers 0-50, Streetlight 2 covers 50-100

Guess you like

Origin blog.csdn.net/shangyanaf/article/details/130926621