codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

315B.md (1857B)


      1 Source: https://codeforces.com/problemset/problem/315/B
      2 
      3 B. Sereja and Array
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 Sereja has got an array, consisting of *n* integers, *a*1, *a*2, ..., *a**n*. Sereja is an active boy, so he is now going to complete *m* operations. Each operation will have one of the three forms:
     22 
     23 1. Make *v**i*-th array element equal to *x**i*. In other words, perform the assignment *a**v**i* = *x**i*.
     24 2. Increase each array element by *y**i*. In other words, perform *n* assignments *a**i* = *a**i* + *y**i* (1 ≤ *i* ≤ *n*).
     25 3. Take a piece of paper and write out the *q**i*-th array element. That is, the element *a**q**i*.
     26 
     27 Help Sereja, complete all his operations.
     28 
     29 Input
     30 
     31 The first line contains integers *n*, *m* (1 ≤ *n*, *m* ≤ 105). The second line contains *n* space-separated integers *a*1, *a*2, ..., *a**n* (1 ≤ *a**i* ≤ 109) — the original array.
     32 
     33 Next *m* lines describe operations, the *i*-th line describes the *i*-th operation. The first number in the *i*-th line is integer *t**i* (1 ≤ *t**i* ≤ 3) that represents the operation type. If *t**i* = 1, then it is followed by two integers *v**i* and *x**i*, (1 ≤ *v**i* ≤ *n*, 1 ≤ *x**i* ≤ 109). If *t**i* = 2, then it is followed by integer *y**i* (1 ≤ *y**i* ≤ 104). And if *t**i* = 3, then it is followed by integer *q**i* (1 ≤ *q**i* ≤ *n*).
     34 
     35 Output
     36 
     37 For each third type operation print value *a**q**i*. Print the values in the order, in which the corresponding queries follow in the input.
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 10 11  
     45 1 2 3 4 5 6 7 8 9 10  
     46 3 2  
     47 3 9  
     48 2 10  
     49 3 1  
     50 3 10  
     51 1 1 10  
     52 2 10  
     53 2 10  
     54 3 1  
     55 3 10  
     56 3 9
     57 ```
     58 
     59 Output
     60 
     61 ```
     62 2  
     63 9  
     64 11  
     65 20  
     66 30  
     67 40  
     68 39
     69 ```