记录编号 1104 评测结果 AAAAAAAAAA
题目名称 [NOIP 2007]统计数字 最终得分 100
用户昵称 GravatarHamster 是否通过 通过
代码语言 Pascal 运行时间 0.558 s
提交时间 2008-07-24 09:10:07 内存使用 0.87 MiB
显示代码纯文本
program heapsort;
var
  a:array[1..200000] of longint;
  i,j,temp,n:longint;
  z:integer;
  fin,fout:text;

procedure init;
begin
  z:=1;
  read(fin,n);
  for i:=1 to n do
  begin
    readln(fin,a[i]);
  end;
end;
procedure qsort(s,t:longint);
var
  i,j,x:longint;
begin
  i:=s;
  j:=t;
  x:=a[(i+j)div 2];
  repeat
    while a[i]<x do inc(i);
    while a[j]>x do dec(j);
    if i<=j then
    begin
      temp:=a[i];
      a[i]:=a[j];
      a[j]:=temp;
      inc(i);dec(j);
    end;
  until i>j;
  if s<j then qsort(s,j);
  if i<t then qsort(i,t);
end;

begin
  assign(fin,'pcount.in');
  reset(fin);
  assign(fout,'pcount.out');
  rewrite(fout);

  init;
  qsort(1,n);
  for i:=1 to n do
  begin
    if i=1 then write(fout,a[i],' ')
    else
    if a[i-1]=a[i] then inc(z)
    else
    begin
      write(fout,z);
      writeln(fout);
      write(fout,a[i],' ');
      z:=1;
    end;
  end;
  write(fout,z);

  close(fin);
  close(fout);
end.