Pagini recente » Cod sursa (job #1057852) | Cod sursa (job #1970080) | Planificare infoarena | Monitorul de evaluare | Cod sursa (job #20356)
Cod sursa(job #20356)
var a,b,c,t:array[0..1024]of integer;
nr:array[1..1024,0..100]of integer;
n,m,i,j,s:integer;
begin
assign(input,'aprindere.in');
reset(input);
assign(output,'aprindere.out');
rewrite(output);
readln(n,m);
for i:=0 to n-1 do read(a[i]);
for i:=1 to m do
begin
read(c[i],t[i],nr[i][0]);
for j:=1 to nr[i][0] do read(nr[i][j]);
b[c[i]]:=i;
end;
s:=0;
for i:=0 to n-1 do
begin
if a[i]=0 then
begin
s:=s+t[b[i]];
for j:=1 to nr[b[i]][0] do
begin
if a[nr[b[i]][j]]=1 then a[nr[b[i]][j]]:=0
else a[nr[b[i]][j]]:=1;
end;
end;
end;
writeln(s);
close(output);
end.