Pagini recente » Cod sursa (job #653644) | Cod sursa (job #2053195) | Cod sursa (job #485009) | Cod sursa (job #522915) | Cod sursa (job #45632)
Cod sursa(job #45632)
{$IFDEF NORMAL}
{$I-,Q-,R-,S-}
{$ENDIF NORMAL}
{$IFDEF DEBUG}
{$I+,Q+,R+,S-}
{$ENDIF DEBUG}
{$IFDEF RELEASE}
{$I-,Q-,R-,S-}
{$ENDIF RELEASE}
var fi,fo:text;
i,n,s:longword;
a:array[1..500002] of longint;
sol:array[1..500002] of char;
procedure go_solve;
var i,j:word;
sum:longint;
solf:boolean;
bulan:longint;
begin
solf:=false;
while not (solf) do
begin
sum:=0;
for i:=1 to n do
begin
randomize;
if sum<s then
begin sum:=sum+a[i]; sol[i]:='+'; continue; end;
if sum>s then
begin sum:=sum-a[i]; sol[i]:='-'; continue; end;
if (sum=s) then
begin
bulan:=random(666013);
if bulan mod 2=0 then
begin sum:=sum+a[i]; sol[i]:='+'; continue; end
else
begin sum:=sum-a[i]; sol[i]:='-'; continue; end;
end;
end;
if sum=s then solf:=true; //am bulan
end;
end;
begin
assign(fi,'semne.in'); reset(fi);
assign(fo,'semne.out'); rewrite(fo);
readln(fi,n,s);
for i:=n downto 1 do
begin
read(fi,a[i]);
end;
go_solve;
for i:=n downto 1 do
write(fo,sol[i]);
close(fo);
end.