QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 512 MB مجموع النقاط: 100

#5467. Reservoir

الإحصائيات

A village has a reservoir with a capacity of $c$. The daily water consumption of the village is known to be $a[1 \dots n]$ (for simplicity, assume water consumption occurs at noon each day). There are $q$ operations:

  • $1 \ x \ y$: Inject $y$ amount of water into the reservoir on the morning of day $x$ (injection occurs before the day's water consumption). Note that the amount of water in the reservoir cannot exceed $c$.
  • $2 \ x \ y$: Change the water consumption of day $x$ to $y$.
  • $3 \ x$: Query the amount of water in the reservoir on the evening of day $x$ (the query occurs after the day's water consumption).

Please simulate the entire process and output the result of each query operation in order.

Input

The first line contains three integers $n, q, c$. The second line contains $n$ integers $a[1 \dots n]$. The next $q$ lines each represent an operation.

Output

Output several lines, representing the results of each query operation.

Constraints

  • For 30% of the data, $n \le 2000$.
  • For another 20% of the data, $c = 10^9$.
  • For 100% of the data, $1 \le n, q \le 10^5, 1 \le c \le 10^9, 0 \le y, a[i] \le 10^4, 1 \le x \le n$.

Examples

Input 1

10 10 100
5 3 1 7 6 4 7 8 3 9
1 5 12
1 2 5
3 3
2 2 1
2 8 30
3 3
2 4 18
1 3 30
2 3 3
3 4

Output 1

1
3
13

Input 2

10 10 20
7 9 3 9 2 2 10 7 9 7
1 4 30
2 9 9
3 2
1 10 24
2 1 17
3 6
1 10 11
2 9 28
3 5
3 1

Output 2

0
7
9
0

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

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.