QOJ.ac

QOJ

実行時間制限: 2 s メモリ制限: 512 MB 満点: 100

#18777. Sequence and Query 19

統計

There is a sequence $A_0, A_1, \ldots, A_{n-1}$ of length $n$. Write a program to execute the following queries:

  • 1 l r c: Add $c$ to all $A_i$ in the interval $l \le i \le r$.
  • 2 l r d: Replace all $A_i$ in the interval $l \le i \le r$ with $\lfloor A_i/d \rfloor$.
  • 3 l r: Output the minimum of all $A_i$ in the interval $l \le i \le r$.
  • 4 l r: Output the sum of all $A_i$ in the interval $l \le i \le r$.

where $\lfloor x \rfloor$ denotes the greatest integer $y$ such that $y \le x$ (for example, $\lfloor -2.5 \rfloor = -3$, $\lfloor -7 \rfloor = -7$).

Input

The first line contains two integers $n$ and $q$ ($1 \le n, q \le 100{,}000$), indicating the length of the sequence and the number of queries.

The second line contains $n$ integers $A_0, A_1, \ldots, A_{n-1}$ ($-10^9 \le A_i \le 10^9$).

Each of the next $q$ lines contains a query ($0 \le l \le r \le n-1$, $-10^4 \le c \le 10^4$, $2 \le d \le 10^9$).

Output

Whenever a query of type 3 or type 4 is encountered, output one answer per line.

Examples

Input 1

10 10
-5 -4 -3 -2 -1 0 1 2 3 4
1 0 4 1
1 5 9 1
2 0 9 3
3 0 9
4 0 9
3 0 1
4 2 3
3 4 5
4 6 7
3 8 9

Output 1

-2
-2
-2
-2
0
1
1

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.