## Editorial for Journey with Pigs

Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Lưu ý: Các code mẫu dưới đây chỉ mang tính tham khảo và có thể không AC được bài tập này

#### Code mẫu của flashmt

const fi='';
fo='';
maxn=1000;
type ar=array[1..maxn] of int64;
var n:longint;
t:int64;
w,d,a,re,w1,a1:ar;

procedure rf;
var i:longint; p:int64;
begin
assign(input,fi);
reset(input);
for i:=1 to n do
begin
a[i]:=p-d[i]*t;
w1[i]:=i; a1[i]:=i;
end;
close(input);
end;

procedure sort(var a,a1:ar;l,r:longint);
var i,j:longint; x,y:int64;
begin
i:=l; j:=r; x:=a[(i+j) div 2];
repeat
while a[i]<x do i:=i+1;
while a[j]>x do j:=j-1;
if i<=j then
begin
y:=a[i]; a[i]:=a[j]; a[j]:=y;
y:=a1[i]; a1[i]:=a1[j]; a1[j]:=y;
i:=i+1; j:=j-1;
end;
until i>j;
if i<r then sort(a,a1,i,r);
if l<j then sort(a,a1,l,j);
end;

procedure pr;
var i:longint;
begin
sort(w,w1,1,n);
sort(a,a1,1,n);
for i:=1 to n do a[a1[i]]:=i;
for i:=1 to n do
re[i]:=w1[a[i]];
end;

procedure wf;
var i:longint;
begin
assign(output,fo);
rewrite(output);
for i:=1 to n do write(re[i],' ');
close(output);
end;

begin
rf;
pr;
wf;
end.


#### Code mẫu của RR

{$R+,Q+} {$Mode objFPC}
uses math;
const
FINP='';
FOUT='';
MAXN=1001;
var
f1,f2:text;
n:longint;
t:int64;
kq,ind1,ind2,w,d:array[1..MAXN] of longint;
p:array[1..MAXN] of int64;
procedure openF;
begin
assign(f1,FINP); reset(f1);
assign(f2,FOUT); rewrite(f2);
end;
procedure closeF;
begin
close(f1);
close(f2);
end;
procedure inp;
begin
for n:=1 to n do read(f1,w[n]);
for n:=1 to n do read(f1,d[n]);
for n:=1 to n do read(f1,p[n]);
for n:=1 to n do p[n]-=d[n]*t;
for n:=1 to n do ind1[n]:=n;
for n:=1 to n do ind2[n]:=n;
end;
procedure swap(var a,b:longint); inline;
var temp:longint;
begin temp:=a; a:=b; b:=temp; end;

procedure swapi(var a,b:int64); inline;
var temp:int64;
begin temp:=a; a:=b; b:=temp; end;

procedure solve;
var
i,j:longint;
begin
for i:=1 to n-1 do
for j:=i+1 to n do
if w[i]>w[j] then
begin
swap(w[i],w[j]);
swap(ind1[i],ind1[j]);
end;
for i:=1 to n-1 do
for j:=i+1 to n do
if p[i]>p[j] then
begin
swapi(p[i],p[j]);
swap(ind2[i],ind2[j]);
end;
for i:=1 to n do
kq[ind2[i]]:=ind1[i];
end;
procedure ans;
begin
for n:=1 to n do
write(f2,kq[n],' ');
end;
begin
openF;
inp;
solve;
ans;
closeF;
end.


#### Code mẫu của hieult

#include <stdio.h>
//#include <conio.h>
void quickSort(long long A[],long long a[], long long lower,long long upper)
{
long long x = A[(lower + upper) / 2];
long long i = lower;
long long j = upper;
do{
while(A[i] < x)
i ++;
while (A[j] > x)
j --;
if (i <= j)
{
long long tg=A[i];
A[i]=A[j];
A[j]=tg;
tg=a[i];
a[i]=a[j];
a[j]=tg;
i ++;
j --;
}
}while(i <= j);
if (j > lower)
quickSort(A,a, lower, j);
if (i < upper)
quickSort(A,a, i, upper);
}
main()
{
long long n,t,w[1001],d[1001],p[1001],a[1001],b[1001],c[1001],e[1001];
scanf("%lld %lld",&n,&t);
for(long long i=1;i<=n;i++)
scanf("%lld",&w[i]);
for(long i=1;i<=n;i++)
scanf("%lld",&d[i]);
for(long i=1;i<=n;i++)
{
scanf("%lld",&p[i]);
c[i]=p[i]-d[i]*t;
a[i]=i;b[i]=i;
}
quickSort(w,a,1,n);
quickSort(c,b,1,n);
for(long i=1;i<=n;i++)
e[b[i]]=i;
for(long i=1;i<=n;i++)
printf("%lld ",a[e[i]]);
//getch();
}


#### Code mẫu của ll931110

{$H+} {$MODE DELPHI}
Program MJOURNEY;
Const
input  = '';
output = '';
maxn = 1000;
Type
rec = record
val,pos: int64;
end;
Var
w,e,k: array[1..maxn] of rec;
d,c,res: array[1..maxn] of integer;
n: integer;
t: int64;

Procedure init;
Var
f: text;
i: integer;
Begin
Assign(f, input);
Reset(f);

For i:= 1 to n do
Begin
w[i].pos:= i;
End;

For i:= 1 to n do read(f, d[i]);
For i:= 1 to n do read(f, c[i]);

Close(f);

For i:= 1 to n do
Begin
e[i].val:= c[i] - d[i] * t;
e[i].pos:= i;
End;
End;

Procedure swap(var x,y: rec);
Var
z: rec;
Begin
z:= x;
x:= y;
y:= z;
End;

Procedure BubbleSort;
Var
i,j: integer;
Begin
For i:= 1 to n - 1 do
For j:= i + 1 to n do
if k[i].val > k[j].val then swap(k[i],k[j]);
End;

Procedure solve;
Var
i: integer;
Begin
k:= w;
BubbleSort;
w:= k;

k:= e;
BubbleSort;
e:= k;

For i:= 1 to n do res[e[i].pos]:= w[i].pos;
End;

Procedure printresult;
Var
f: text;
i: integer;
Begin
Assign(f, output);
Rewrite(f);
For i:= 1 to n do write(f, res[i], ' ');
Close(f);
End;

Begin
init;
solve;
printresult;
End.


#### Code mẫu của khuc_tuan

//{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q+,R+,S+,T-,U-,V+,W-,X+,Y+,Z1} // {$APPTYPE CONSOLE}
{\$mode delphi}

type
ArInt64 = array[1..1000] of int64;
ArInt32 = array[1..1000] of integer;

var
i, n, t : integer;
w, d, p : ArInt64;
r, iw, ip : ArInt32;

procedure sort(var a : ArInt64; var p : ArInt32);
var
i,j,t : integer;
begin
for i:=1 to n do
for j:=i+1 to n do
if a[p[j]] > a[p[i]] then
begin
t := p[i];
p[i] := p[j];
p[j] := t;
end;
end;

begin
for i:=1 to n do read(w[i]);
for i:=1 to n do read(d[i]);
for i:=1 to n do
begin
p[i] := p[i] - d[i] * t;
iw[i] := i;
ip[i] := i;
end;
sort( w, iw);
sort( p, ip);
for i:=1 to n do r[ip[i]] := iw[i];
for i:=1 to n do write(r[i], #32);
end.