Pagini recente » Cod sursa (job #169307) | Cod sursa (job #321862) | Cod sursa (job #2669474) | Cod sursa (job #1351328) | Cod sursa (job #140252)
Cod sursa(job #140252)
program plus;
var f,g:Text;
a,b,i,s,t1,t2,t3: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 (s+1>t3+1)then n:=t3+1 else n:=s+1;
n:=n*(t1+1);
end;
write(g,n);
close(f);
close(g);
end.