QOJ.ac

QOJ

時間限制: 4 s 記憶體限制: 512 MB 總分: 100

#18787. Ciąg i zapytanie 29

统计

Dany jest ciąg $A_1, A_2, \ldots, A_N$ o długości $N$ oraz ciąg $B$ o długości $N$, który na początku ma $B_i = 0$. Napisz program wykonujący następujące zapytania:

  • 1 L R X: Dla wszystkich $L \le i \le R$ ustaw $A_i = A_i + X$.
  • 2 L R Y: Dla wszystkich $L \le i \le R$ ustaw $A_i = \max(A_i, Y)$.
  • 3 L R Y: Dla wszystkich $L \le i \le R$ ustaw $A_i = \min(A_i, Y)$.
  • 4 L R: Wypisz $B_L + B_{L+1} + \ldots + B_R$.

Gdy zapytanie typu 1, 2 lub 3 powoduje zmianę wartości $A_i$, wówczas wartość $B_i$ jest zwiększana o $1$.

Wejście

Pierwszy wiersz zawiera rozmiar ciągu $N$. ($1 \le N \le 500\,000$)

Drugi wiersz zawiera $A_1, A_2, \ldots, A_N$. ($-10^9 \le A_i \le 10^9$)

Trzeci wiersz zawiera liczbę zapytań $M$. ($1 \le M \le 500\,000$)

Następne $M$ wierszy opisuje każde zapytanie. ($1 \le L \le R \le N$, $-2\,000 \le X \le 2\,000$, $-10^9 \le Y \le 10^9$) Co najmniej jedno zapytanie jest typu 4.

Wyjście

Dla każdego zapytania typu 4 wypisz w osobnym wierszu wynik.

Przykład

Wejście 1

5
1 2 3 4 5
11
4 1 5
1 1 3 3
4 1 5
2 2 5 5
4 1 5
3 1 4 5
4 1 4
2 1 5 0
4 1 5
3 1 5 1
4 1 2

Wyjście 1

0
3
4
5
5
4

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.