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
zcmu-1245: Trainsorting(双端队列超简单做法)
最新推荐文章于 2023-05-30 14:11:21 发布
Erin是一名工程师,她需要将火车车厢按重量降序排列,但只能在车头或车尾添加车厢。给定每节车厢的重量和到达顺序,目标是找出能构建的最长合规火车。输入包含车厢数量和各车厢重量,输出最长火车的车厢数。一道适合运用双端队列解决的简单问题。
摘要由CSDN通过智能技术生成