Cod sursa(job #8221)

Utilizator VmanDuta Vlad Vman Data 23 ianuarie 2007 22:38:59
Problema Aprindere Scor 100
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.71 kb
program aprindere;
var n,m,x,i,j:integer;
    b:array[0..1000]of byte;
    t,nrc:array[0..1000]of integer;
    c:array[0..1000]of boolean;
    cc:array[0..1000,0..1000]of integer;
    f:text;
    tot:longint;
begin
assign(f,'aprindere.in');reset(f);
readln(f,n,m);
for i:=0 to n-1 do
  read(f,b[i]);
readln(f);
for i:=1 to m do begin
    read(f,x);
    read(f,t[x],nrc[x]);
    c[x]:=true;
    for j:=1 to nrc[x] do
        read(f,cc[x][j]);
    readln(f);
end;
close(f);

tot:=0;
for i:=0 to n-1 do
    if b[i]=0 then begin
       inc(tot,t[i]);
       for j:=1 to nrc[i] do
           b[cc[i][j]]:=1-b[cc[i][j]];
    end;
assign(f,'aprindere.out');rewrite(f);
write(f,tot);
close(f);
end.