传统题 1000ms 128MiB

奶牛排队

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Description

Bob 的农场养了 <math xmlns="http://www.w3.org/1998/Math/MathML">n 头奶牛,每天奶牛们都要经历漫长的排队打饭的过程。

为了排解长时间排队带来的焦虑,<math xmlns="http://www.w3.org/1998/Math/MathML">Bob 让他的奶牛们玩一个游戏,让每头奶牛找出他的左侧第 <math xmlns="http://www.w3.org/1998/Math/MathML">1 头比自己体重轻的奶牛。

请你编程帮助 <math xmlns="http://www.w3.org/1998/Math/MathML">Bob 计算出答案,方便他验证奶牛们计算的正确性。

Input Format

第 <math xmlns="http://www.w3.org/1998/Math/MathML">1 行输入一个整数 <math xmlns="http://www.w3.org/1998/Math/MathML">n,表示奶牛的数量。(<math xmlns="http://www.w3.org/1998/Math/MathML">1<n106

第 <math xmlns="http://www.w3.org/1998/Math/MathML">2 行有空格隔开的 <math xmlns="http://www.w3.org/1998/Math/MathML">n 个整数 <math xmlns="http://www.w3.org/1998/Math/MathML">ai,代表奶牛的身高(<math xmlns="http://www.w3.org/1998/Math/MathML">1ai105)。

Output Format

输出 n 个整数,用空格隔开,表示每头奶牛左侧第 1 头体重小于自己的奶牛的体重,如果某头奶牛左侧没有比自己轻的奶牛,请输出整数 0
5
50 80 100 90 70
0 50 80 80 50

Source

单调栈 简单问题

单调队列单调栈

未参加
状态
已结束
规则
ACM/ICPC
题目
7
开始于
2024-5-26 13:00
结束于
2024-6-18 17:00
持续时间
556 小时
主持人
参赛人数
0