Cod sursa(job #403421)

Utilizator ISZLAIIszlai Lehel ISZLAI Data 24 februarie 2010 22:09:11
Problema Datorii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.6 kb
#include<fstream>
#include<iostream>
using namespace std;
int main ()
{ ifstream f;ofstream g;
f.open("datorii.in" );
g.open("datorii.out" );
int tart[15000]={0},muv[100000][3];
  
  int t,v,p,q;
	int n,m,s;
	f>>n;
	f>>m;
		for(int i=0;i<n;i++)
				f>>tart[i];
		for(int j=0;j<m;j++)
			for(int k=0;k<3;k++)
			f>>muv[j][k];
	
	for(int j=0;j<m;j++)
		if(muv[j][0]==0)
		{t=muv[j][1];v=muv[j][2];
		tart[t-1]=tart[t-1]-v;
		}
			else if(muv[j][0]==1)
		{p=muv[j][1];q=muv[j][2];s=0;
		for(int k=p-1;k<q;k++)
			{
		s=s+tart[k];
		}g<<s<<'\n';
		}
		return 0;
               
}