[Fzyzoj 1889] Kitchen Relief

Source: Internet
Author: User

P1889--Kitchen relief

Time limit: 1000MS

Memory Limit: 131072KB

Description

As we all know, Lzl owned n Kitchen, once was troubled by water pipe problem, in a certain God (Zhang) (GE) (GE) son (?) With the help of the plumbing exchanger, the kitchen finally worked normally. But Lzl recently met with new problems ...

Because the dish he made was so delicious (as his body), a lot of people are in batches to each kitchen to eat, which mainly have small z, small G, small c, small k and other people, which makes lzl very headache, because people are really too much, he can not quickly know how many kitchen or a kitchen there are a number of people, can not be in time to assign the chef to cope.

Now, Lzl found you and asked for help.

Input Format

Line 1th N, K stands for n Kitchens, K batches of people

The 2nd line has n numbers, indicating the number of people in each kitchen

From 3rd to k+2, each line has a q,a and B:

If q = 1, there is a and B, the kitchen labeled A is added to the B person (very strange, B is always greater than 0!). )

If q = 2, then there is a and B, which means you can output the total number of people in the kitchen (A, B)

Output Format

For each q=2 query, output the corresponding value

Sample Input
5 31 2 3 4 5 2 1 31 2 22 2 5
Sample Output
616
Hint

30% N <=, K <= 1000

50% N <=10000, K <= 10000

100% N <= 100000 K <= 100000

All the answers are within the Longlong range.

Zgg: Who is the mysterious man?

LZL: Ask CK, his question I don't know

Zgg: Lying trough, this is called the title? I finished 2 seconds.

LZL: ...

Exercises

Tree-like array bare topic

1#include <stdio.h>2 Charb[1<< the],*s=b,*t=B;3 #defineGetc () (s==t&& (t= (s=b) +fread (B,1,1<<15,stdin), s==t)? 0:*s++)4 intn,m,b[100001],c[100001],a[100001];5 intLowbit (intx) {returnx& (-x);}6 intGetint () {7     intx=0, f=1;CharCh=getc ();8      while(ch<'0'|| Ch>'9') {if(ch=='-') f=-1; Ch=getc ();}9      while(ch>='0'&&ch<='9') {x= (x<<3) + (x<<1) +ch-'0'; Ch=getc ();}Ten     returnx*F; One } A voidModifyintXintDelta) { -      -      while(x<=N) { thec[x]+=Delta; -x+=lowbit (x); -     } - }  + intCalintx) { -     intret=0; +      while(x!=0) { Aret+=C[x]; atx-=lowbit (x); -     } -     returnret; - } - Main () { -N=getint (); m=getint (); in      for(intI=1; i<=n;++i) { -b[i]=getint (); toa[i]=b[i]+a[i-1]; +c[i]=a[i]-a[i-lowbit (i)]; -     } the      while(m--) { *         intxx=getint (); $         if(xx==2) {Panax Notoginseng             intP,q;p=getint (); q=getint (); -printf"%d\n", Cal (q)-cal (P-1)); the         } +         if(xx==1) { A             intP,q; P=getint (); q=getint (); the Modify (p,q); +         } -     } $}
View Code

[Fzyzoj 1889] Kitchen Relief

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.