QOJ.ac

QOJ

Límite de tiempo: 5 s Límite de memoria: 1024 MB Puntuación total: 100

#18799. Sequence and Query 41

Estadísticas

You are given a sequence $A_1, A_2, \ldots, A_N$ of length $N$. Write a program to execute the following queries:

  • 0 l r x: For all $l \le i \le r$, assign $A_i$ to $\max(A_i, x)$.
  • 1 l r: Output $\max\left(0, \max_{l \le u \le v \le r} \left(\sum_{i=u}^{v} A_i\right)\right)$.

Input

The first line contains two integers $N$ and $Q$, representing the length of the sequence and the number of queries.

The second line contains $N$ integers $A_1, A_2, \ldots, A_N$, the initial elements of the sequence $A$.

The next $Q$ lines each describe a query in the format above.

Output

For each query of the form 1 l r, output a line with the answer.

Examples

Input 1

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

Output 1

3
6
7
5
18
26
39

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.