Cod sursa(job #75816)

Utilizator hazegirlCatalina Predoi hazegirl Data 6 august 2007 01:51:42
Problema A+B Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.45 kb
#include<fstream.h>
void main()
{int n,m,i,j,k,c,tc,nrc,a[999],s=0,x;
fstream f("aprindere.in",ios::in);
fstream g("aprindere.out",ios::out);
f>>n>>m;
for(i=0;i<=n-1;i++)
     f>>a[i];
while(!feof(f))
       { f>>c;
	 if (a[c]==0)
	    {f>>tc;
	     s+=tc;
	     f>>nrc;
	     for(j=1;j<=nrc;j++)
			{f>>x;
			 if (a[x]==0)	a[x]=1;
			 else a[x]=0;
			 };
	     };
	     else {f>>tc>>nrc; for(j=1;j<=n;j++) f>>x;};
	     };
g<<s;

}