O(n log n) 模拟,排序;
var n,k,i:longint; a,b,c:array[0..30000] of longint;PRocedure qsort(l,r:longint);var p,t,m,j:longint;begin i:=l;j:=r; p:=a[(l+r) div 2]; m:=c[(l+r) div 2]; repeat while (a[i]>p)or((a[i]=p)and(c[i]<m)) do inc(i); while (a[j]<p)or((a[j]=p)and(c[j]>m)) do dec(j); if i<=j then begin t:=a[i];a[i]:=a[j];a[j]:=t; t:=c[i];c[i]:=c[j];c[j]:=t; inc(i); dec(j); end; until i>j; if i<r then qsort(i,r); if l<j then qsort(l,j);end;procedure init;begin readln(n,k); for i:=1 to 10 do read(b[i]); for i:=1 to n do read(a[i]);end;begin init; for i:=1 to n do c[i]:=i; qsort(1,n); for i:=1 to n do a[i]:=a[i]+b[(i-1) mod 10+1]; qsort(1,n); for i:=1 to k do write(c[i],' ');end.新闻热点
疑难解答