比赛 |
暑假培训六 |
评测结果 |
AAAAATATTA |
题目名称 |
统计数字 |
最终得分 |
70 |
用户昵称 |
辨机ZN |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-07-23 11:46:53 |
显示代码纯文本
program ex(f1,f2);
type
zn=array [1..200000] of longint;
ma=array [1..200000] of longint;
var
a:zn; f1,f2:text; i,j,n,m,k:longint;
b,c:ma;
procedure paixu(left,right:longint);
var x,y,l,r:longint;
begin
l:=left; r:=right; x:=a[(l+r) div 2];
repeat
while a[l]<x do inc(l);
while a[r]>x do dec(r);
if l<=r then
begin
y:=a[l];
a[l]:=a[r];
a[r]:=y;
inc(l);
dec(r);
end;
until l>r;
if l<right then paixu(l,right);
if r>left then paixu(left,r);
end;
begin
assign(f1,'pcount.in'); reset(f1);
assign(f2,'pcount.out'); rewrite(f2);
readln(f1,n);
for i:=1 to n do readln(f1,a[i]);
paixu(1,n); j:=1; b[1]:=a[1]; c[1]:=1;
for i:=2 to n do
begin
if a[i]<>b[j] then begin
inc(j);
b[j]:=a[i];
end;
inc(c[j]);
end;
for i:=1 to j do writeln(f2,b[i],' ',c[i]);
close(f1);
close(f2);
end.