讨论 / 大神请进
Justin_N_Wu 2016-01-04 21:43:49
点我顶贴 收藏 删除
const maxn=50005;

var n,k:longint;

a:array[0..maxn] of record

id:longint;

w:int64;

end;

e:array[0..10] of int64;

procedure init;

var i:longint;

begin

// assign(input,'jiajia.in');reset(input);

// assign(output,'jiajia.out');rewrite(output);

readln(n,k);

for i:=1 to n do begin

read(a[i].w);

a[i].id:=i;

end;

readln;

for i:=1 to 10 do read(e[i]);

end;

procedure qsort(L,R:longint);

var i,j:longint;

midw,midi:int64;

begin

i:=L;j:=R;midw:=a[random(R-L+1)+L].w;midi:=a[random(R-L+1)+L].id;

repeat

while (a[i].w>midw)or((a[i].w=midw)and(a[i].id<midi)) do inc(i);

while (a[j].w<midw)or((a[j].w=midw)and(a[j].id>midi)) do dec(j);

if i<=j then begin

a[0]:=a[i];a[i]:=a[j];a[j]:=a[0];

inc(i);dec(j);

end;

until i>j;

if i<R then qsort(i,R);

if L<j then qsort(L,j);

end;

procedure main;

var i:longint;

begin

qsort(1,n);

for i:=1 to n do inc(a[i].w,e[(a[i].id-1) mod 10+1]);

qsort(1,n);

end;

procedure print;

var i:longint;

begin

for i:=1 to k-1 do write(a[i].id,' ');

writeln(a[k].id);

//close(input);close(output);

end;

begin

init;

main;

print;

end.

为什么只有十分?百思不得其解啊,求助。

查看更多回复
提交回复