Cod sursa(job #2784954)
Utilizator | Enal Gemaledin Blaugranas | Data | 17 octombrie 2021 19:03:52 |
---|---|---|---|
Problema | Datorii | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.46 kb |
#include<fstream>
using namespace std;
int n,m,x,y,s,t[15001];
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;
}