Dynamic maximum sum (2)

Here, you have to efficiently keep a list of integer numbers, which is initially empty. Let the current list be x0,,xn1x_0, \dots, x_{n-1}. There are just two operations:

Input

Input consists of several cases. Every case begins with the number of operations mm, followed by the mm operations. We have an M for reporting the maximum, and I xx jj for inserting. Assume 1m21051 \le m \le 2 \cdot 10^5, 1012x1012-10^{12} \le x \le 10^{12}, and that jj is between 0 and the current list size.

Output

For every case, and for every M operation, print the maximum sum of consecutive elements inside the current list. Print a line with 10 dashes at the end of each case.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T12:04:46.789Z

© Jutge.org, 2006–2026.
https://jutge.org