Cod sursa(job #20308)

Utilizator hazegirlCatalina Predoi hazegirl Data 21 februarie 2007 00:08:01
Problema Aprindere Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.48 kb
#include<fstream.h>
int main()
{int n,m,i,j,k,c,tc,nrc,a[1000],s=0,x;
ifstream f("aprindere.in");
ofstream g("aprindere.out");
f>>n>>m;
for(i=0;i<=n-1;i++)
     f>>a[i];
for(i=1;i<=m;i++)
       { 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<=nrc;j++)
			 f>>x;};
	     };
g<<s;     f.close(); g.close();
    return 0;
}