Cod sursa(job #407574)

Utilizator tudgal1001Profir Tudor tudgal1001 Data 2 martie 2010 14:06:43
Problema Aprindere Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.56 kb
#include<stdio.h>
using namespace std;

int main ()
{
	int timp_tot,i,j,n,m,x,t,nr,c[101],st[1001];
	timp_tot=0;
	freopen("aprindere.in","r",stdin);
	freopen("aprindere.out","w",stdout);
	scanf("%d %d",&n,&m);
	for (i=0; i<n; i++)
		scanf("%d",&st[i]);
	for (i=1; i<=m; i++)
	{
		scanf("%d %d %d",&x,&t,&nr);
		for (j=1; j<=nr; j++)
			scanf("%d",&c[j]);
		if (st[x]==0)
		{
			timp_tot+=t;
			for (j=1; j<=nr; j++)
			{
				if (st[c[j]]==1) st[c[j]]=0;
				else if (st[c[j]]==0) st[c[j]]=1;
			}
		}
	}
	printf("%d",timp_tot);
	return 0;
}