CodeForces-767A Snacktower

这道题目描述了一个关于Ankh-Morpork居民如何按照大小顺序构建Snacktower的故事。居民们每天收到一个不同大小的零食,必须按大小顺序从大到小堆叠。输入包含零食总数n和每天收到的零食大小,输出为每天堆叠的零食顺序。题目要求在所有比当前零食大的零食都出现后才能放置新的零食。解题关键在于跟踪已出现的零食并正确输出顺序。
摘要由CSDN通过智能技术生成

time limit: per test2 seconds
memory limit: per test256 megabytes
input: standard input
output: standard output

According to an old legeng, a long time ago Ankh-Morpork residents did something wrong to miss Fortune, and she cursed them. She said that at some time n snacks of distinct sizes will fall on the city, and the residents should build a Snacktower of them by placing snacks one on another. Of course, big snacks should be at the bottom of the tower, while small snacks should be at the top.

Years passed, and once different snacks started to fall onto the city, and the residents began to build the Snacktower.

这里写图片描述

However, they faced some troubles. Each day exactly one snack fell onto the city, but their order was strange. So, at some days the residents weren’t able to put the new stack on the top of the Snacktower: they had to wait until all the bigger snacks fell. Of course, in order to not to anger miss Fortune again, the residents placed each snack on the top of the tower immediately as they could do it.

Write a program that models the behavior of Ankh-Morpork residents.

Input
The first line contains single integer n (1 ≤ n ≤ 100 000) — the total number of snacks.

The second line contains n integers, the i-th of them equals the

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
04-27 2000
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值