type
as=record
m,f:string;
end;
var
y:as;
s:array[0..5000] of as;
i,j,n:longint;
function p(a,b:string):boolean;
var
i,j,l1,l2:longint;
begin
l1:=length(a);
l2:=length(b);
if l1>l2 then begin p:=true; exit; end;
if l1<l2 then begin p:=false; exit; end;
for i:=1 to l1 do
begin
if a[i]>b[i] then begin p:=true; exit;end;
if a[i]<b[i] then begin p:=false; exit;end;
end;
end;
procedure h(i,m:integer);
var
y:as;
begin
while i*2<=m do
begin
i:=i*2;
if (i<m)and((p(s[i+1].f,s[i].f))or((s[i+1].f=s[i].f)and(p(s[i+1].m,s[i].m))))then inc(i);
if (p(s[i].f,s[i div 2].f))or((s[i].f=s[i div 2].f)and(p(s[i].m,s[i div 2].m))) then
begin
y:=s[i];
s[i]:=s[i div 2];
s[i div 2]:=y;
end
else break;
end;
end;
begin
readln(n);
for i:=1 to n do
begin
readln(s[i].m);
readln(s[i].f);
if s[i].f[1]=’0’ then
for j:=1 to length(s[i].f) do
begin
if s[i].f[j]=’0’ then delete(s[i].f,j,1);
if s[i].f<>’0’ then break;
end;
end;
for i:=n div 2 downto 1 do
h(i,n);
for i:=n downto 2 do
begin
y:=s[i];
s[i]:=s[1];
s[1]:=y;
h(1,i-1);
end;
for i:=n downto 1 do
writeln(s[i].m);
end.
Unaccepted
测评机: Xeost[5]
得分: 80分
提交日期: 2008-11-6 17:03:00
有效耗时: 1625毫秒
测试结果1: 通过本测试点|有效耗时187:ms
测试结果2: 通过本测试点|有效耗时172:ms
测试结果3: 通过本测试点|有效耗时172:ms
测试结果4: 测试结果错误.
测试结果5: 通过本测试点|有效耗时219:ms
测试结果6: 通过本测试点|有效耗时219:ms
测试结果7: 通过本测试点|有效耗时203:ms
测试结果8: 通过本测试点|有效耗时250:ms
测试结果9: 通过本测试点|有效耗时203:ms
测试结果10:测试结果错误.
第四个和第十个点,过不了,诚求讲解!谢谢!感激不尽!!!!!!!!!!!!!
仰望!!!!