CF315B.Sereja and Array

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Sereja has got an array, consisting of nn integers, a1,a2,...,ana_{1},a_{2},...,a_{n} . Sereja is an active boy, so he is now going to complete mm operations. Each operation will have one of the three forms:

  1. Make viv_{i} -th array element equal to xix_{i} . In other words, perform the assignment avi=xia_{vi}=x_{i} .
  2. Increase each array element by yiy_{i} . In other words, perform nn assignments ai=ai+yia_{i}=a_{i}+y_{i} (1<=i<=n)(1<=i<=n) .
  3. Take a piece of paper and write out the qiq_{i} -th array element. That is, the element aqia_{qi} .

Help Sereja, complete all his operations.

输入格式

The first line contains integers nn , mm (1<=n,m<=105)(1<=n,m<=10^{5}) . The second line contains nn space-separated integers a1,a2,...,ana_{1},a_{2},...,a_{n} (1<=ai<=109)(1<=a_{i}<=10^{9}) — the original array.

Next mm lines describe operations, the ii -th line describes the ii -th operation. The first number in the ii -th line is integer tit_{i} (1<=ti<=3)(1<=t_{i}<=3) that represents the operation type. If ti=1t_{i}=1 , then it is followed by two integers viv_{i} and xix_{i} , (1<=vi<=n,1<=xi<=109)(1<=v_{i}<=n,1<=x_{i}<=10^{9}) . If ti=2t_{i}=2 , then it is followed by integer yiy_{i} (1<=yi<=104)(1<=y_{i}<=10^{4}) . And if ti=3t_{i}=3 , then it is followed by integer qiq_{i} (1<=qi<=n)(1<=q_{i}<=n) .

输出格式

For each third type operation print value aqia_{qi} . Print the values in the order, in which the corresponding queries follow in the input.

输入输出样例

  • 输入#1

    10 11
    1 2 3 4 5 6 7 8 9 10
    3 2
    3 9
    2 10
    3 1
    3 10
    1 1 10
    2 10
    2 10
    3 1
    3 10
    3 9
    

    输出#1

    2
    9
    11
    20
    30
    40
    39
    
首页