Pagini recente » Cod sursa (job #1285622) | Cod sursa (job #183916) | Cod sursa (job #2936049) | Cod sursa (job #1656128) | Cod sursa (job #147488)
Cod sursa(job #147488)
var m,c,t,n,i,d,nr,t1,b:longint;
a:array[1..30000] of byte;
f,g:text;
ok,p:boolean;
begin
assign(f,'aprindere.in'); reset(f);
readln(f,n,m); c:=-1; t1:=0;
for i:=1 to n do
read(f,a[i]);
ok:=true;
for i:=1 to n do
if a[i]=0 then begin if not eoln then p:=true;
while (c<>i) and (not eoln) and p do begin
read(f,c,t,nr); if i=c then begin for d:=1 to nr do begin
read(f,b);
if b>i then if a[b]=1 then a[b]:=0
else a[b]:=1;
t1:=t1+t;
end;
p:=false;
end;
readln(f);
end;
end;
assign(g,'aprindere.out'); rewrite(g);
writeln(g,t1);
close(f); close(g);
end.