Cod sursa(job #1333733)
Utilizator | Data | 3 februarie 2015 15:31:04 | |
---|---|---|---|
Problema | Datorii | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.42 kb |
#include <iostream>
#include<fstream>
using namespace std;
int n,m,w[15001],i,t,v,q,a,s,p,j;
int main()
{
ifstream f("datorii.in");
ofstream g("datorii.out");
f>>n>>m;
for(i=1;i<=n;i++)f>>w[i];
for(i=1;i<=m;i++)
{
f>>a;
if(a==0)f>>t>>v;
else f>>p>>q;
if(a==0)w[t]=w[t]-v;
else {for(j=p;j<=q;j++)s=s+w[j];g<<s<<endl;s=0;}
}
return 0;
}