Pagini recente » Cod sursa (job #1229390) | Cod sursa (job #30249) | Cod sursa (job #1837820) | Cod sursa (job #306038) | Cod sursa (job #14259)
Cod sursa(job #14259)
var poz,i,j,time,n,m:longint;
lu:array[0..1000] of 0..1;
ma:array[1..1000,1..1000] of 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(lu[i]);
for i:=1 to m do
begin
read(ma[i,1],ma[i,2],ma[i,3]);
for j:=4 to ma[i,3]+3 do
read(ma[i,j]);
end;
for i:=0 to n-1 do
begin
if lu[i]=0 then
begin
for j:=1 to m do
if ma[j,1]=i then poz:=j;
time:=time+ma[poz,2];
for j:=4 to ma[poz,3]+3 do
begin
if lu[ma[poz,j]]=0 then lu[ma[poz,j]]:=1
else lu[ma[poz,j]]:=0;
end;
end;
end;
write(time);
close(input);
close(output);
end.