Pagini recente » Cod sursa (job #122840) | Cod sursa (job #3221543) | Concursul Mihai Patrascu 2013 | Cod sursa (job #1183645) | Cod sursa (job #482674)
Cod sursa(job #482674)
var f1,f2:text; n,m,i,x,b,c,nr,j,s,p:longint; a:array[1..1000] of integer;
begin
assign(f1,'aprindere.in');
reset(f1);
assign(f2,'aprindere.out');
rewrite(f2);
read(f1,n,m);
s:=0;
for i:=1 to n do read(f1,a[i]);
for i:=1 to m do begin
read(f1,b);
read(f1,c);
read(f1,nr);
inc(b);
if a[b]=0 then
begin
for j:=1 to nr do
begin
read(f1,x);
p:=x+1;
if a[p]=1 then a[p]:=0
else a[p]:=1;
end;
s:=s+c;
end
else readln(f1);
end;
write(f2,s);
close(f1);
close(f2);
end.