Pagini recente » Cod sursa (job #2744418) | Cod sursa (job #818873) | Cod sursa (job #1158151) | Cod sursa (job #1892120) | Cod sursa (job #584839)
Cod sursa(job #584839)
type punct=record
x:longint;
y:char;
end;
var i,n,k,s,j:longint;
v:array[1..50000]of punct;
ok:boolean;
begin
assign(input,'semne.in');reset(input);
assign(output,'semne.out');rewrite(output);
Randomize;
read(n);
read(k);
ok:=true;
for i:=1 to n do read(v[i].x);
while ok do begin
for i:=1 to n do begin
if random(1000) mod 2=1 then v[i].y:='+'else v[i].y:='-';
if v[i].y='-'then s:=s-v[i].x else s:=s+v[i].x;
end;
if s=k then begin
ok:=false;
for j:=1 to n do write(v[j].y);
end else s:=0;
end;
end.