Cod sursa(job #517426)
| Utilizator | Data | 28 decembrie 2010 18:49:02 | |
|---|---|---|---|
| Problema | Datorii | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int n, m, a[15000], k, p, q, s=0;
ifstream fin("datorii.in");
ofstream fout("datorii.out");
fin>>n>>m;
for (int i=0; i<n; i++){
fin>>a[i];
//cout<<a[i]<<" ";
}
for (int i=1; i<=m; i++){
fin>>k>>p>>q;
if (k==0)
a[p-1]=a[p-1]-q;
else {
for (int j=p-1; j<q; j++)
s+=a[j];
cout<<s<<endl;
s=0;
}
//cout<<k<<" "<<p<<" "<<q<<endl;
}
}
