1 条题解

  • 0
    @ 2021-6-15 10:13:25

    Pascal :

    var
    n,m,i,z,o,l:integer;
    k,a:array[1..5000]of integer;
    
    procedure qsort(l,h:integer);
    var i,j,t,m,max:integer;
    begin
    i:=l;
    j:=h;
    m:=a[(i+j)div 2];
    repeat
    while a[i]<m do inc(i);
    while m<a[j] do dec(j);
    if i<=j then
    begin
    t:=a[i];   max:=k[i];
    a[i]:=a[j]; k[i]:=k[j];
    a[j]:=t;  k[j]:=max;
    inc(i);
    dec(j);
    end;
    until i>j;
    if j>l then qsort(l,j);
    if i<h then qsort(i,h);
    end;
    
    begin
      readln(n,m);
      for i:=1 to n do read(k[i],a[i]);
      qsort(1,n);
      z:=trunc(1.5*m);
      for i:=1 to n do
       if a[i]=a[n-z+1] then begin o:=i;break;end;
      writeln(a[n-z+1],' ',n-o+1);
      for i:=n downto o do
      begin
      if a[i]=a[i-1] then if k[i]>k[i-1] then begin z:=k[i];k[i]:=k[i-1];k[i-1]:=z;end;
      writeln(k[i],' ',a[i]);end;
    end.
    
    • 1

    信息

    ID
    451
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者