记录编号 |
1052 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[NOIP 2007]统计数字 |
最终得分 |
100 |
用户昵称 |
辨机ZN |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.468 s |
提交时间 |
2008-07-23 20:27:57 |
内存使用 |
2.40 MiB |
显示代码纯文本
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.