#C10555. Managing Drone Fleet Operations

    ID: 39773 Type: Default 1000ms 256MiB

Managing Drone Fleet Operations

Managing Drone Fleet Operations

In this problem, you are required to simulate operations on a fleet of drones. Each drone is equipped with a battery and the battery level is an integer between 0 and 100. There are two types of operations:

  • Type 1: Update the battery levels of drones in the range \(l\) to \(r\) by adding an integer value \(v\). After the update, each battery level is clamped to remain within the range \([0, 100]\).
  • Type 2: Query the average battery level (rounded down) of drones in the range \(l\) to \(r\). The average is computed as \(\left\lfloor\frac{\sum_{i=l}^{r} battery_i}{r-l+1}\right\rfloor\).

Your task is to process \(q\) operations and output the result for every Type 2 operation.

inputFormat

The input is given via standard input (stdin) and has the following format:

  1. The first line contains two integers \(n\) and \(q\) where \(n\) is the number of drones and \(q\) is the number of operations.
  2. The second line contains \(n\) integers representing the initial battery levels of the drones.
  3. The following \(q\) lines each represent an operation. If the operation is of Type 1, the format is: 1 l r v. If it is of Type 2, the format is: 2 l r. Note that all indices are 1-indexed.

outputFormat

For each Type 2 operation, output a single line containing the floor of the average battery level of the specified drones.

## sample
5 3
50 60 70 80 90
1 1 3 10
2 1 5
2 2 4
76

76

</p>