#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
//贪心 谢谢博友好分析
double n,t;
struct pig{
double num;
double w;
};
struct vill{
double num;
double d;
double p;
};
vector<struct pig> va;
vector<struct vill> vb;
double a[1020];
double b[1020];
bool fa(struct pig a,struct pig b){
return a.w>b.w;
}
bool fb(struct vill a,struct vill b)
{
return (a.p-(a.d*t))>(b.p-(b.d*t));
}
struct dy{
double p;
double v;
};
vector<struct dy> vc;
bool fc(struct dy a,struct dy b)
{
return a.v<b.v;
}
int main()
{
va.clear();
vb.clear();
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
vc.clear();
cin>>n>>t;
for(int i=1;i<=n;i++)
{
double x;
cin>>x;
struct pig tp;
tp.num=i;
tp.w=x;
va.push_back(tp);
}
for(int i=1;i<=n;i++)
{
double x;
cin>>x;
a[i]=x;
}
for(int i=1;i<=n;i++)
{
double x;
cin>>x;
b[i]=x;
}
for(int i=1;i<=n;i++)
{
struct vill tv;
tv.num=i;
tv.d=a[i];
tv.p=b[i];
vb.push_back(tv);
}
/*
cout<<n<<" "<<t<<endl;
for(int i=1;i<=n;i++)
{
cout<<va[i-1].w<<" ";
}
cout<<endl;
for(int i=1;i<=n;i++)
{
cout<<vb[i-1].d<<" ";
}
cout<<endl;
for(int i=1;i<=n;i++)
{
cout<<vb[i-1].p<<" ";
}
cout<<endl;*/
sort(va.begin(),va.end(),fa);
/*
cout<<endl;
for(int i=0;i<n;i++)
{
cout<<va[i].w<<" ";
}
cout<<endl;*/
sort(vb.begin(),vb.end(),fb);
/*
cout<<endl;
for(int i=0;i<n;i++)
{
cout<<vb[i].num<<" ";
}
cout<<endl;*/
for(int i=0;i<n;i++)
{
struct dy temp;
temp.p=va[i].num;
temp.v=vb[i].num;
vc.push_back(temp);
}
sort(vc.begin(),vc.end(),fc);
for(int i=0;i<n;i++)
{
cout<<vc[i].p<<" ";
}
cout<<endl;
return 0;
}
POJ 3544 Journey with Pigs C++ 贪心
于 2017-02-18 18:51:18 首次发布