Cod sursa(job #140239)

Utilizator antoanelaAntoanela Siminiuc antoanela Data 21 februarie 2008 16:12:44
Problema Plus Scor 25
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.6 kb
program plus;
var f,g:Text;
    a,b,i,t1,t2,t3,s:longint;
    n:int64;
begin
assign(f,'plus.in');
assign(g,'plus.out');
reset(f);
rewrite(g);
read(f,s);
for i:=1 to 3 do
  begin
    read(f,a,b);
    if (b=0)then t1:=t1+a else
    if (b=1)then t2:=t2+a else
    if (b=-1)then t3:=t3+a;
  end;
if (t2=0)and(s=0)then n:=1+t1 else
if (t3=0)and(s=0)then n:=1+t1 else
if (t2<s)and(s>0)then n:=0 else
begin
  if (s=0)then
    if (t2>t3)then n:=t3+1 else n:=t2+1 else
  if (s>0)then
    if (t2-s+1>t3+1)then n:=t3+1 else n:=t2-s+1;
  n:=n*(t1+1);
end;
write(g,n);
close(f);
close(g);
end.