比赛 |
暑假培训六 |
评测结果 |
AAAAEEEEEA |
题目名称 |
统计数字 |
最终得分 |
50 |
用户昵称 |
Hamster |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-07-23 11:13:53 |
显示代码纯文本
program heapsort;
var
a:array[1..10001] of longint;
i,j,temp,n,z:longint;
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],' ');
if (i<>1) and (a[i-1]=a[i]) then inc(z);
if (i<>1) and (a[i-1]<>a[i]) then
begin
write(fout,z);
writeln(fout);
write(fout,a[i],' ');
z:=1;
end;
end;
write(fout,z);
close(fin);
close(fout);
end.