zcmu-1245: Trainsorting(双端队列超简单做法)

Erin是一名工程师,她需要将火车车厢按重量降序排列,但只能在车头或车尾添加车厢。给定每节车厢的重量和到达顺序,目标是找出能构建的最长合规火车。输入包含车厢数量和各车厢重量,输出最长火车的车厢数。一道适合运用双端队列解决的简单问题。
摘要由CSDN通过智能技术生成

1245: Trainsorting

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 54  Solved: 43
[Submit][Status][Web Board]

Description

Erin is an engineer. She drives trains. She also arranges the cars within each train. She prefers to put the cars in decreasing order of weight, with the heaviest car at the front of the train.

Unfortunately, sorting train cars is not easy. One cannot simply pick up a car and place it somewhere else. It is impractical to insert a car within an existing train. A car may only be added to the beginning and end of the train.

Cars arrive at the train station in a predetermined order. When each car arrives, Erin can add it to the

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值