讨论 / 求大神解答哪里错了,最后只有九十分,
a704152094 2014-01-04 17:02:37
点我顶贴 收藏 删除
var

n,k,i,t,h:longint;

w,e,a:array[1..100000]of longint;

procedure as(r,l:longint);

var

x,i,j,v:longint;

begin

x:=w[(r+l) div 2];

i:=r;

j:=l;

repeat

while w[j]<x do

j:=j-1;

while w[i]>x do

i:=i+1;

if i<=j then

begin

v:=w[i];

w[i]:=w[j];

w[j]:=v;

v:=a[i];

a[i]:=a[j];

a[j]:=v;

i:=i+1;

j:=j-1;

end;

until i>j;

if r<j then as(r,j);

if i<l then as(i,l);

end;

begin

readln(n,k);

for i:=1 to 10 do

read(e[i]);

readln;

for i:=1 to n do

read(w[i]);

for i:=1 to n do

a[i]:=i;

as(1,n);

for i:=1 to n-1 do

begin

t:=i+1;

while w[i]=w[t] do

begin

if a[i]>a[t] then

begin

h:=a[i];

a[i]:=a[t];

a[t]:=h;

end;

t:=t+1;

end;

end;

for i:=1 to n do

w[i]:=w[i]+e[(i-1) mod 10+1];

as(1,n);

for i:=1 to n-1 do

begin

t:=i+1;

while w[i]=w[t] do

begin

if a[i]>a[t] then

begin

h:=a[i];

a[i]:=a[t];

a[t]:=h;

end;

t:=t+1;

end;

end;

for i:=1 to k-1 do

write(a[i],' ');

write(a[k]);

end.

#1 renyanyu345@2014-01-21 19:48:19
回复 删除
抄的吧!
查看更多回复
提交回复