Pagini recente » Cod sursa (job #467645) | Cod sursa (job #2943870) | Cod sursa (job #781934) | Cod sursa (job #255211) | Cod sursa (job #119454)
Cod sursa(job #119454)
var f1,f2:text;
a:array[1..50000] of longint;
c:array[1..50000] of char;
i,n,x:longint;
s,sg:int64;
begin
randomize;
assign(f1,'semne.in');
reset(f1);
assign(f2,'semne.out');
rewrite(f2);
read(f1,n,s);
for i:=1 to n do
read(f1,a[i]);
while sg<>s do
begin
sg:=0;
for i:=1 to n do
begin
x:=random(2);
if x=0 then
begin
c[i]:='+';
sg:=sg+a[i];
end
else
begin
c[i]:='-';
sg:=sg-a[i];
end;
end;
end;
for i:=1 to n do write(f2,c[i]);
close(f1);
close(f2);
end.