1 条题解
- 
  0
贪心。
将一斤猪肉来到某个村庄后的利润算出来,并以此将村庄从小到大排序。要使利润最大化,必然在利润大的村庄卖重的,所以猪按重量从大到小排序。
然后就没有然后了,挺显然的一道题。
#include<bits/stdc++.h> #define ll long long using namespace std; const int N = 10000 + 10; int n, T, ans[N]; struct pig{ ll w, id; bool operator < (const pig &p) const {return w > p.w;} } p[N]; struct town{ ll dis, val, id; bool operator < (const town &p) const {return val > p.val;} } t[N]; int main(){ scanf("%d%lld", &n, &T); for(int i=1;i<=n;i++) scanf("%lld", &p[i].w), p[i].id = i; for(int i=1;i<=n;i++) scanf("%lld", &t[i].dis), t[i].id = i; for(int i=1;i<=n;i++){ ll v; scanf("%lld", &v); t[i].val = v - t[i].dis * T;//一斤猪肉来到这个村庄后可以买多少钱 } sort(p + 1, p + 1 + n); sort(t + 1, t + 1 + n); for(int i=1;i<=n;i++) ans[t[i].id] = p[i].id; for(int i=1;i<=n;i++) printf("%lld ", ans[i]); return 0; } 
信息
- ID
 - 2809
 - 时间
 - 1000ms
 - 内存
 - 256MiB
 - 难度
 - 8
 - 标签
 - 递交数
 - 30
 - 已通过
 - 7
 - 上传者