|
|
вернуться в форумPROBLEM WITH A PROBLEM Why this source got WA#13 var a:array[1..5000]of longint; n,k,i,j,l,r,mid,com,cout:longint; procedure sort(l,r: longint); var i,j,x,y: longint; begin i:=l; j:=r; x:=a[(l+r) DIV 2]; repeat while a[i]<x do i:=i+1; while x<a[j] do j:=j-1; if i<=j then begin y:=a[i]; a[i]:=a[j]; a[j]:=y; i:=i+1; j:=j-1; end; until i>j; if l<j then sort(l,j); if i<r then sort(i,r); end; begin read(n); for i:=1 to n do read(a[i]); sort(1,n); mid:=-maxlongint; cout:=1; com:=0; for i:=2 to n do if a[i]=a[i-1] then inc(cout) else if cout>mid then begin mid:=cout; cout:=1; com:=a[i-1]; end; if ((com=0)and(n>0)) then com:=a[1] else if (mid<cout) then com:=a[n] else if ((com=0)and(n=0)) then com:=0; write(com); end. Edited by author 16.03.2007 10:55 Re: PROBLEM WITH A PROBLEM 3 of course No subject Edited by author 16.03.2007 10:54 Re: Why Edited by author 16.03.2007 10:56 |
|
|