⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 middle.pas

📁 Magio牛的usaco源代码
💻 PAS
字号:
{
PROB:middle
LANG:PASCAL
}

program middle;
const
  maxn=9999;
var
  a:array[1..maxn]of longint;
  n,m,i:word;
procedure qsort(s,t:word);
  var
    p,i,j:word;
    ta:longint;
  begin
    if (s>=t) or (t<m) or (s>m) then exit;
    p:=s+random(t-s+1);
    ta:=a[p];a[p]:=a[s];
    i:=s;j:=t;
    repeat
      while (i<j) and (a[j]>=ta) do dec(j);
      if i=j then break;a[i]:=a[j];inc(i);
      while (i<j) and (a[i]<=ta) do inc(i);
      if i=j then break;a[j]:=a[i];dec(j);
    until i=j;
    a[i]:=ta;
    qsort(s,i-1);
    qsort(i+1,t);
  end;
begin
  assign(input,'middle.in');reset(input);
  assign(output,'middle.out');rewrite(output);
  read(n);m:=n shr 1+1;
  for i:=1 to n do
    read(a[i]);
  qsort(1,n);
  writeln(a[m]);
  close(input);close(output);
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -