Cod sursa(job #2785132)
Utilizator | Data | 18 octombrie 2021 05:29:45 | |
---|---|---|---|
Problema | Datorii | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.47 kb |
#include<fstream>
using namespace std;
int m,s,t[15001];
short n,x,y;
bool c;
ifstream f("datorii.in");
ofstream o("datorii.out");
int main()
{
for(f>>n>>m,y=1;y<=n;++y)
for(f>>x,s=y;s<=n;t[s]+=x,s+=(s&-s));
while(m--) {
f>>c>>x>>y;
if(c) {
for(s=0;y;s+=t[y],y-=(y&-y));
for(--x;x;s-=t[x],x-=(x&-x));
o<<s<<'\n';
} else
for(;x<=n;t[x]-=y,x+=(x&-x));
}
return 0;
}