Cod sursa(job #483371)

Utilizator andrei.dAndrei Diaconeasa andrei.d Data 8 septembrie 2010 12:29:42
Problema Aprindere Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.78 kb
#include <cstdio>

#define file_in "aprindere.in"
#define file_out "aprindere.out"

#define nmax 1010
#define mmax 101

int N,M;
int V[nmax];
int T[nmax];
int C;
int Nr[nmax];
int X[nmax][mmax];

void adfile(void){
	
	freopen(file_in,"r",stdin);
	freopen(file_out,"w",stdout);
	
	int i,j;
	
	scanf("%d %d", &N, &M);
	for (i=0;i<N;++i)
		 scanf("%d", &V[i]);
	for (i=1;i<=M;++i){
		scanf("%d", &C);
		scanf("%d %d", &T[C], &Nr[C]);
		for (j=1;j<=Nr[C];++j)
			 scanf("%d", &X[C][j]);
	}
	
	fclose(stdin);
	
	return ;
	
}

void solve(void){
	
	int suma=0,i,j;
	for (i=0;i<N;++i)
		if (!V[i]){
			
			suma+=T[i];
			for (j=1;j<=Nr[i];++j)
				 V[X[i][j]]^=1;
		}
	
	printf("%d\n", suma);
}	

int main(){
	
	adfile();
	solve();
	
	return 0;
	
}