Cod sursa(job #1607325)
Utilizator | Data | 20 februarie 2016 23:35:50 | |
---|---|---|---|
Problema | Datorii | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.48 kb |
#include<fstream>
#define maxs 15005
using namespace std;
ifstream fin("datorii.in");
ofstream fout("datorii.out");
int v[maxs], N, M;
int main(){
int i, o, x, y, s, j;
fin >> N >> M;
for(i=1; i<=N; ++i)
fin >> v[i];
for(i=1; i<=M; ++i){
fin >> o >> x >> y;
if(o){
s=0;
for(j=x; j<=y; ++j)
s+=v[j];
fout<<s<<'\n';
}
else{
v[x]-=y;
}
}
}