Cod sursa(job #14239)

Utilizator alex_mircescuAlex Mircescu alex_mircescu Data 8 februarie 2007 15:41:27
Problema Aprindere Scor 0
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..300,1..100] of integer;

begin
assign(input,'aprinder.in');reset(input);
assign(output,'aprinder.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.