#C10105. Process Array Queries

    ID: 39274 Type: Default 1000ms 256MiB

Process Array Queries

Process Array Queries

You are given an integer array A of length N and a series of Q queries. Each query is described by two integers T and X. There are five types of queries:

  • Type 1: Append X to the end of the array.
  • Type 2: Remove the last element of the array (if it exists).
  • Type 3: Add X to every element in the array.
  • Type 4: Multiply every element in the array by X.
  • Type 5: Output the minimum element currently in the array (if the array is not empty).

Perform the queries in the given order. For each query of type 5, print the minimum element on a new line. If a query does not require output, do nothing for that query.

The arithmetic update queries (types 3 and 4) apply to every element in the array as described by the following formulas:

  • For type 3 (increment): \(a_i = a_i + X\) for each element \(a_i\).
  • For type 4 (multiplication): \(a_i = a_i \times X\) for each element \(a_i\).

Note: For queries of type 5, it is guaranteed that the array will contain at least one element.

inputFormat

The input is given from standard input in the following format:

N Q
A[0] A[1] ... A[N-1]
T1 X1
T2 X2
... 
TQ XQ

Where the first line contains two integers N and Q representing the initial number of elements in the array and the number of queries respectively. The second line contains N integers representing the initial array A. Each of the next Q lines contains two integers T and X representing a query.

outputFormat

For each query of type 5, output the minimum element of the array on a separate line.

## sample
5 5
3 1 4 1 5
1 9
3 2
5 0
4 3
5 0
3

9

</p>