【UVA1289】Stacking Plates

本文介绍了盘子运输公司的成本分析问题,公司在打包盘子发货过程中发现花费了大量的时间和金钱。问题在于盘子需要先堆叠起来再放入运输箱。为了降低成本,需要将不同制造商的盘子组合成一个堆栈,允许的操作包括分割和合并。分割是将一个堆栈分为两个,合并是将两个堆栈按正确顺序叠加在一起,但只有当顶部堆栈的底部盘子不大于底部堆栈的顶部盘子时才能进行。题目要求找到将所有堆栈合并为一个堆栈所需的最小操作数。输入包含堆栈数量和每个堆栈的盘子直径,输出是最小操作数。
摘要由CSDN通过智能技术生成

Description

The Plate Shipping Company is an Internet retailer that, as their name suggests, exclusively sells plates. They pride themselves in offering the widest selection of dinner plates in the universe from a large number of manufacturers.

In a recent cost analysis the company has discovered that they spend a large amount of money on packing the plates for shipment. Part of the reason is that plates have to be stacked before being put into shipping containers. And apparently, this is taking more time than expected. Maybe you can help.

A shipment of plates consists of plates from several manufacturers. The plates from each manufacturer come stacked, that is, each arranged in a single stack with plates ordered by size (the smallest at the top, the largest at the bottom). We will call such a stackproperly ordered. To ship all these plates, you must combine them into a single stack, again properly ordered. To join the manufacturers' stacks into a single stack, two kinds of operations are allowed:


  • Split: a single stack can be split into two stacks by lifting any top portion of the stack and putting it aside to form a new stack.
  • Join: two stacks can be joined by putting one on top of the other. This is allowed only if the bottom plate of the top stack is no larger than the top plate of the bottom stack, that is, the joined stack has to be properly ordered.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值