Delivery Man(贪心)

10 篇文章 0 订阅

在这里插入图片描述
一开始以为可以用优先队列写,每次选择小费最多的,结果WA,正确的贪心思想是按照两个数的差排序,然后每次选择小费最多的即可。
代码如下:

#include<bits/stdc++.h>
#define LL long long
#define Max 100005
#define Mod 1e9+7
const LL mod=1e9+7;
const LL inf=0x3f3f3f3f;
using namespace std;
struct node
{
	int x,y;
}a[Max];
bool cmp(node a,node b)
{
	return abs(a.x-a.y)>abs(b.x-b.y);
}
int main()
{
	int n,ans=0;
	int x,y;
	scanf("%d%d%d",&n,&x,&y);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i].x);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i].y);
	sort(a,a+n,cmp);
	for(int i=0;i<n;i++)
	{
		if(a[i].x>=a[i].y && x)
		{
			ans+=a[i].x;
			x--;
		}
		else if(y)
		{
			ans+=a[i].y;
			y--;
		}
	}
	printf("%d\n",ans);
    return 0;
}

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Delivery optimization refers to the process of efficiently managing and planning the delivery of goods or services from a warehouse, distribution center, or point of origin to the end customers. It involves various strategies, techniques, and technologies to minimize costs, reduce lead times, improve customer satisfaction, and enhance overall supply chain performance. Key aspects of delivery optimization include: 1. Route planning: Determining the most efficient routes for delivery vehicles to minimize travel distance and time, taking into account traffic patterns, delivery priorities, and vehicle capacity. 2. Inventory management: Optimizing inventory levels to ensure that products are available when needed, without excessive storage costs or stockouts. 3. Warehouse operations: Streamlining warehouse processes such as picking, packing, and sorting to minimize handling time and maximize productivity. 4. Real-time tracking: Using GPS and other technologies to monitor shipments in real-time, enabling better visibility and proactive problem-solving. 5. Load balancing: Distributing packages evenly among delivery personnel or vehicles to optimize resource utilization and reduce wait times. 6. Customer experience: Implementing features like dynamic delivery windows, same-day or next-day deliveries, and accurate tracking information to enhance customer satisfaction. 7. Sustainability: Incorporating eco-friendly practices, such as electric or hybrid vehicles, to reduce carbon footprint and promote green logistics. 8. Supply chain integration: Collaborating with suppliers, carriers, and other stakeholders to synchronize data and improve coordination across the entire delivery network.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值