Catch the vibe! https://www.youtube.com/watch?v=SBaITnCSsnQ
Every living person collects memories, happy or sad; and everybody keeps moving on regardless of what they go through because life does not stop. Sometimes you may notice that the days you thought you were sad were actually happy moments. Sometimes, you think you are living in the worst days possible when they are not at all bad. Throughout your life, you learn non-stop and prepare for something bigger. Yet this is usually realized quite late.
In this question, we will examine life. Happiness of a life... Think about a timeline that represents the memories in a lifetime. The author of this question keeps a timeline to mark the happiness score of his life. But obviously, happiness is not a constant, everybody has bad days. Normally, these days should be marked with negative values. But again, the author of this question does not do that in hopes of maybe getting over them one day. So, the timeline actually contains the emotion depth of the author's feelings with all positive values.
The author also believes that after every
Initially, an array of happiness scores will be given to calculate the total happiness score of a part of his life. When calculating total happiness of a time interval, you will be given left and right indexes. You should calculate the total happiness according to the given rule in the previous paragraph with assuming the first
Two operations will be asked to perform in every query:
- The author wants to change the happiness score of a memory
- The author wants to learn the total happiness score of a life part. Help him do the calculations!
First line consists of three integers
Second line consists of
The next
- If
$query\ type$ is$1$ , then the next two integers are$i$ and$v$ , where$v$ is the new value of$i$ 'th memory. - If
$query\ type$ is$2$ , then the next two integers are$l$ and$r$ , where$l$ is the leftmost and$r$ is the rightmost index of the life part that you need to calculate the total happiness scores for (including the rightmost index).
For each query with type
10 5 3
1 2 3 4 5 6 7 8 9 10
2 0 9
1 1 12
2 0 9
2 1 4
2 7 9
5
15
14
27