记录编号 73784 评测结果 AAAAAAAAAA
题目名称 [NOIP 2009]分数线划定 最终得分 100
用户昵称 Gravatargungnir 是否通过 通过
代码语言 Pascal 运行时间 0.028 s
提交时间 2013-10-22 21:51:52 内存使用 0.20 MiB
显示代码纯文本
var a:array[0..5005,1..2]of longint;
    n,m,i,k,num:longint;


procedure qsort(l,r:longint);
var i,j,mid,temp:longint;
begin
i:=l; j:=r; mid:=a[(l+r)div 2,2];
   while(i<=(l+r)div 2)and(j>=(l+r)div 2) do
   begin
       while (a[i,2]<mid)or
       ((a[i,2]=mid)and(a[i,1]>a[(l+r)div 2,1])) do inc(i);
       while (a[j,2]>mid)or
       ((a[j,2]=mid)and(a[j,1]<a[(l+r)div 2,1])) do dec(j);
       if i<=j then
       begin
         if (a[i,2]>a[j,2])or
            (a[i,2]=a[j,2])and(a[i,1]<a[j,1]) then
         begin
         temp:=a[i,1]; a[i,1]:=a[j,1]; a[j,1]:=temp;
         temp:=a[i,2]; a[i,2]:=a[j,2]; a[j,2]:=temp;
         end;
       end;


   inc(i); dec(j);
   end;
if i<r then qsort(i,r);
if l<j then qsort(l,j);
end;

begin
assign(input,'score.in');reset(input);
assign(output,'score.out');rewrite(output);
readln(n,m);
m:=trunc(m*1.5);
for i:=1 to n do readln(a[i,1],a[i,2]);
qsort(1,n);
num:=a[(n-m+1),2];
k:=1;
while(a[k,2]<num)do inc(k);
writeln(num,' ',n-k+1);
for i:= n downto k do writeln(a[i,1],' ',a[i,2]);
close(input);close(output);
end.