Problem J. Journey with Pigs
http://codeforces.com/gym/241680/problem/J
考察排序不等式
算出来单位重量在每个村庄的收益,然后生序排列
猪的重量也生序排列
此时价值最大
#include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<set>
#include<map>
#include<stack>
#include<cstring>
#define inf 2147483647
#define ls rt<<1
#define rs rt<<1|1
#define lson ls,nl,mid,l,r
#define rson rs,mid+1,nr,l,r
#define N 100010
#define For(i,a,b) for(long long i=a;i<=b;i++)
#define p(a) putchar(a)
#define g() getchar() using namespace std;
long long n,t;
long long dis[];
struct value{
long long poi;
long long v;
}a[]; struct pig{
long long poi;
long long w;
}b[];
long long ans[]; void in(long long &x){
long long y=;
char c=g();x=;
while(c<''||c>''){
if(c=='-')y=-;
c=g();
}
while(c<=''&&c>=''){
x=(x<<)+(x<<)+c-'';c=g();
}
x*=y;
}
void o(long long x){
if(x<){
p('-');
x=-x;
}
if(x>)o(x/);
p(x%+'');
} bool cmp1(pig a,pig b){
return a.w<b.w;
} bool cmp2(value a,value b){
return a.v<b.v;
} int main(){
freopen("journey.in","r",stdin);
freopen("journey.out","w",stdout);
in(n);in(t);
For(i,,n){
in(b[i].w);
b[i].poi=i;
}
sort(b+,b+n+,cmp1);
For(i,,n)
in(dis[i]);
For(i,,n){
in(a[i].v);
a[i].poi=i;
}
For(i,,n)
a[i].v=a[i].v-dis[i]*t;
sort(a+,a+n+,cmp2);
For(i,,n)
ans[a[i].poi]=b[i].poi;
For(i,,n-){
o(ans[i]);p(' ');
}
o(ans[n]); return ;
}