cf Sereja and Array

http://codeforces.com/contest/315/problem/B

 1 #include <cstdio>

 2 #include <cstring>

 3 #include <iostream>

 4 #include <algorithm>

 5 #define maxn 200000

 6 using namespace std;

 7 

 8 int a[maxn],b[maxn],c,v,x;

 9 

10 int main()

11 {

12     int n,m;

13     cin>>n>>m;

14     for(int i=0; i<n; i++)

15     {

16         cin>>a[i];

17     }

18     int ans=0;

19     for(int i=0; i<m; i++)

20     {

21         cin>>c;

22         if(c==1)

23         {

24             cin>>v>>x;

25             a[v-1]=x-ans;

26         }

27         else if(c==2)

28         {

29             cin>>x;

30             ans+=x;

31         }

32         else if(c==3)

33         {

34             cin>>v;

35             cout<<a[v-1]+ans<<endl;

36         }

37     }

38     return 0;

39 }
View Code

 

你可能感兴趣的:(array)