|
|
вернуться в форумhelp WA3 program Project2; {$APPTYPE CONSOLE} uses SysUtils; var a,b:array[1..10001] of integer; t,i,n,t1,t2,j:longint; begin { assign(input,'d:\input.txt'); reset(input); assign(output,'d:\output.txt'); rewrite(output);} readln(n); if n=1 then begin write(1); exit; end; for i:=1 to n do begin read(a[i]); b[i]:=i; end; for i:=1 to n-1 do for j:=i+1 to n do if a[i]<a[j] then begin a[i]:=a[i]+a[j]; a[j]:=a[i]-a[j]; a[i]:=a[i]-a[j]; b[i]:=b[i]+b[j]; b[j]:=b[i]-b[j]; b[i]:=b[i]-b[j]; end; t:=-1; a[n+1]:=-1; repeat if (t<>b[1]) and (a[1]<>0) then begin t:=b[1]; a[1]:=a[1]-1; end else if (t<>b[2]) and (a[2]<>0) then begin t:=b[2]; a[2]:=a[2]-1; end; i:=1; while a[i]<a[i+1] do begin j:=i+1; a[i]:=a[i]+a[j]; a[j]:=a[i]-a[j]; a[i]:=a[i]-a[j]; b[i]:=b[i]+b[j]; b[j]:=b[i]-b[j]; b[i]:=b[i]-b[j]; i:=i+1; end; i:=2; while a[i]<a[i+1] do begin j:=i+1; a[i]:=a[i]+a[j]; a[j]:=a[i]-a[j]; a[i]:=a[i]-a[j]; b[i]:=b[i]+b[j]; b[j]:=b[i]-b[j]; b[i]:=b[i]-b[j]; i:=i+1; end; write(t,' '); until (a[2]=0); if t<>b[1] then write(b[1]); { sleep(112121);} { close(input); close(output); } end. give me wrong test, please! |
|
|