Sum insertion

Please implement an efficient data structure to support just one
operation. Let x₁, …, x_(n) be the current elements (natural numbers) in
the data structure, all different and in increasing order. Given three
parameters y, i, and j, you must insert
z = (y + ∑_(i ≤ k ≤ j)x_(k)) mod  10⁹ into your data structure. Assume
that you start with just one element, with value 0.

Input

Input begins consists of several cases. Each case starts with the number
of insertions m. Follow m triples y i j. Assume 1 ≤ m ≤ 10⁵,
0 ≤ y < 10⁹, and 1 ≤ i ≤ j ≤ n. The end of input is indicated with a
special case with m = 0.

Output

For every operation, if z is a new value, insert z and print I z.
Otherwise, do not insert z and print R z. Print a line with 10 dashes at
the end of each case.

Problem information

Author: Pol Mauri

Generation: 2026-01-25T12:00:51.265Z

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