【Atcoder - AGC027B】Garbage Collector

该博客讨论了一个关于机器人清理房间垃圾的问题。机器人从原点出发,需要将分布在数轴上的垃圾搬运到垃圾箱,消耗能量进行移动、拾取和丢弃垃圾。问题要求找到最小的能量消耗策略。博客提到了一个贪心算法,先到达最远的垃圾位置,然后在返回过程中拾取垃圾。博主还提醒注意防止数值溢出,并提供了问题的分析和解决方案。
摘要由CSDN通过智能技术生成

@Garbage Collector@


@题目描述 - English@

Time limit : 2sec / Memory limit : 1024MB

Score : 700 points

Problem Statement
Snuke has decided to use a robot to clean his room.

There are N pieces of trash on a number line. The i-th piece from the left is at position xi. We would like to put all of them in a trash bin at position 0.

For the positions of the pieces of trash, 0 < x1 < x2 < … < xN ≤ 10^9 holds.

The robot is initially at position 0. It can freely move left and right along the number line, pick up a piece of trash when it comes to the position of that piece, carry any number of pieces of trash and put them in the trash bin when it comes to position 0. It is not allowed to put pieces of trash anywhere except in the trash bin.

The robot consumes X points of energy when the robot picks up a piece of trash, or put pieces of trash in the trash bin. (Putting any number of pieces of trash in the trash bin consumes X points of energy.) Also, the robot consumes (k+1)^2 points of energy to travel by a distance of 1 when the robot is carrying k pieces of trash.

Find the minimum amount of energy required to put all the N pieces of trash in the trash bin.

Constraints
1≤N≤2×10^5
0 < x1 < … < xN≤10^9

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值