Pagini recente » Cod sursa (job #3227998) | Cod sursa (job #622801) | Cod sursa (job #1723701) | Cod sursa (job #2177333) | Cod sursa (job #20610)
Cod sursa(job #20610)
var a,b,c,t:array[0..1024]of longint;
nr:array[1..1024,1..1024]of longint;
n,m,i,j,s:longint;
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]);
readln;
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.