|
|
back to boardIt's Impossible here is my code. In my computer he got AC on test#1. But in timus that got WA#1 var a:array[0..500010] of longint; procedure sort(l,r:longint); var i,j,p,x:longint; begin randomize; i:=l; j:=r; x:=a[random(r-l+1)+l]; repeat while x>a[i] do inc(i); while x<a[j] do dec(j); if i<=j then begin p:=a[i];a[i]:=a[j];a[j]:=p; inc(i); dec(j); end; until i>j; if i<r then sort(i,r); if l<j then sort(l,j); end; var p,j,k,n,i,temp,have:longint; begin readln(n); for i:=1 to n do readln(a[i]); sort(1,n); temp:=-1; for i:=1 to n do begin if a[i]=temp then begin inc(have); continue; end; if n mod 2=1 then k:=1 else k:=0; if have>=n div 2+k then begin writeln(temp); halt; end; have:=1;temp:=a[i]; end; if n=1 then writeln(temp); end. |
|
|