Pagini recente » Cod sursa (job #1736672) | Rating Persicanu Andrei-Rodion (Mexicanu69) | Cod sursa (job #1902218) | Cod sursa (job #3155552) | Cod sursa (job #12483)
Cod sursa(job #12483)
var fi,fo:text;
n,m,i,j,x:integer;
rez:longint;
mat:array[0..1000,0..100]of integer;
c,st:array[0..1000]of integer;
begin
assign(fi,'aprindere.in'); reset(fi);
assign(fo,'aprindere.out'); rewrite(fo);
readln(fi,n,m);
for i:=0 to n-1 do read(fi,st[i]);
for i:=1 to m do
begin
read(fi,x); read(fi,c[x]);
read(fi,mat[x][0]);
for j:=1 to mat[x][0] do
read(fi,mat[x][j]);
end;
rez:=0;
for i:=0 to n-1 do
if st[i]=0 then
begin
rez:=rez+c[i];
for j:=1 to mat[i][j]do
st[mat[i][j]]:=1-st[mat[i][j]];
end;
writeln(fo,rez);
close(fo);
end.