Cod sursa(job #14259)

Utilizator alex_mircescuAlex Mircescu alex_mircescu Data 8 februarie 2007 16:35:56
Problema Aprindere Scor 100
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.73 kb
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.